Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 renaming route for "create" action

# routes.rb
resource: :users, only: :create, path_names: { create: 'register' }

Following the routing guide at guides.rubyonrails.org, this line is expected to replace /users with /users/register, but the path_names argument seems to have no effect whatsoever. What am I doing wrong?

EDIT: Interesting that it only applies to new and edit. In any case, this is the work around I used

resource :users, only: :nothing do
  post "register", to: :create
end

Done this way to make it slightly easier to enable more actions for users in the future

like image 496
alpanik Avatar asked Dec 04 '25 08:12

alpanik


1 Answers

From rails guide:

The :path_names option lets you override the automatically-generated "new" and "edit" segments in paths

It seems that you can't rename the create action.

like image 180
Pierre-Louis Gottfrois Avatar answered Dec 08 '25 17:12

Pierre-Louis Gottfrois



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!