I have been working my way through the Railscasts videos and trying to adapt them for the latest version of rails, being version 6. I am up to the following episode:
http://railscasts.com/episodes/124-beta-invitations
The video explains that you need to have some form of authorisation/authentication in place prior to the changes, so I followed the instructions on the following site to do so:
https://www.nopio.com/blog/authentication-authorization-rails/
I stopped at Step 20 as the final step was not needed. Here devise is the main gem used for most of the heavy lifting.
Now as far as the railscast goes I am at the point where we need to alter the signup path, which is where I am stuck, and the example given, of a change to routes file, is as follows:
map.signup '/signup/:invitation_token', :controller => 'users', :action => 'new'
There is also a comment from some time after going down the same path as me and using devise which shows the following:
devise_for :users, :controllers => {:registrations => 'registrations'} do
get 'users/sign_up/:invitation_token' => 'devise/registrations#new', :as => "new_user_registration"
end
After entering the above and running rails routes, I cannot find any changes to the entry, ie. the addition of the :invitation_token and the sign_up path still looks as follows:
new_user_registration GET /users/sign_up(.:format) registrations#new
My understanding is it should look like:
new_user_registration GET /users/sign_up/:invitation_token(.:format) registrations#new
If someone could point in the right direction, it would be greatly appreciated :)
Please let me know if any additional information is required to assist in a solution?
as far as I'm aware devise doesn't let you modify the default registration path using devise_for
(see the method docs: https://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3adevise_for)
what you can do instead is use the devise_scope
.
devise_scope :user do
post 'users/sign_up/:invitation_token', to: 'registrations#new', as: 'new_user_registration'
end
note that because you are using your own registrations controller you need to point the new path to use this controller, not the devise one.