在我的路线中,我有:
resources :accounts
这会产生:
accounts GET /accounts(.:format) accounts#index
POST /accounts(.:format) accounts#create
new_account GET /accounts/new(.:format) accounts#new
edit_account GET /accounts/:id/edit(.:format) accounts#edit
account GET /accounts/:id(.:format) accounts#show
PUT /accounts/:id(.:format) accounts#update
DELETE /accounts/:id(.:format) accounts#destroy
我只想更改以下资源路径:
new_account GET /accounts/new(.:format) accounts#new
到
new_account GET /register(.:format) accounts#new
这可能吗?
答案 0 :(得分:1)
是的,您可以将控制器中的任何操作与特定路线匹配。
只需将该行添加到routes.rb
即可match "/register" => "accounts#new"
答案 1 :(得分:0)
您在routes.rb
match 'register' => 'accounts#new'