ruby-on-rails – 添加新的路由操作
发布时间:2020-12-16 22:34:31 所属栏目:百科 来源:网络整理
导读:我在用户控制器中收到了这些操作 class UsersController ApplicationController def index #default action ... end def new #default action ... end def another_new ... end def create ... end def another_create ... endend 我想要能够 / users / anot
我在用户控制器中收到了这些操作
class UsersController < ApplicationController def index #default action ... end def new #default action ... end def another_new ... end def create ... end def another_create ... end end 我想要能够 我得到以下config / routes.rb get '/users/another_new' :to => 'users#another_new' resources :users 我的问题是如果这是添加get的正确方法以及如何添加another_create方法. 解决方法
在你的config / routes.rb文件中这样做
resources :users do collection do get 'another_new' post 'another_create' end end 还要看看HERE,以清楚理解概念. 希望这可以帮助你吗? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |