In Rails 4 I'm trying to make a custom root for a particular action in the users controller, so i want my restful resources for users still like they are, but change only the url for the create
action and make it to be for example /account/register
. I'm trying do this as the follow but it seem not work :
resources :users, except: [:create] # first i eliminate creation of create root
resources :users, path: "account/register", as: :users, only: [:create] # then i just try to make a custom route for only create action
i want still using users_path and not change any of my routing helper in the view, please any idea ?
How about:
post "/account/register" => "users#create", as: :users
This will create a route where /account/register
points to UsersController#create. This can be referenced with users_path
.
尝试:
match '/account/register' => 'user#create', via: :post
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.