Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registration routes are confusing #2505

Closed
tkawa opened this issue Jul 14, 2013 · 1 comment
Closed

Registration routes are confusing #2505

tkawa opened this issue Jul 14, 2013 · 1 comment

Comments

@tkawa
Copy link

@tkawa tkawa commented Jul 14, 2013

Devise makes the following registration routes:

# config/routes.rb
# devise_for :users

       user_registration POST   /users(.:format)         devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format) devise/registrations#new
cancel_user_registration GET    /users/cancel(.:format)  devise/registrations#cancel
  edit_user_registration GET    /users/edit(.:format)    devise/registrations#edit
                         PATCH  /users(.:format)         devise/registrations#update
                         PUT    /users(.:format)         devise/registrations#update
                         DELETE /users(.:format)         devise/registrations#destroy

These routes have a few problems.

  • These confuse the resource which represents "all users" and the resource which represents "myself"
  • also confuse "users" as a resource and "users" as a namespace
  • What is the "registrations" which does not correspond to URL?

Proposal

#create and #new are the actions for all users.
The rest are the actions for myself.

Therefore, it should make two distinct resources.

For example:

              users POST   /users(.:format)               users#create
           new_user GET    /users/new(.:format)           users#new
cancel_current_user GET    /current_user/cancel(.:format) current_users#cancel
  edit_current_user GET    /current_user/edit(.:format)   current_users#edit
       current_user PATCH  /current_user(.:format)        current_users#update
                    PUT    /current_user(.:format)        current_users#update
                    DELETE /current_user(.:format)        current_users#destroy

Using the gem I created makes these routes.
https://github.com/tkawa/devise-better_routes

This is more intuitive and appropriate for Rails way, isn't it?

I propose to change the default routing as described above.

@josevalim

This comment has been minimized.

Copy link
Contributor

@josevalim josevalim commented Jul 14, 2013

Thanks for the proposal. Yes, it make sense, even though we have originally decided to not pollute two namespaces for the same Devise controller. Unfortunately, this is a very backwards incompatible change, so any change of this dimension would have to wait until Devise 4.0 (and we just released 3.0). Fortunately, you can customize it on your own, as you did. :)

So I am closing this but leaving a note to myself that we could possibly revisit this (in a year or two).

@josevalim josevalim closed this Jul 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.