简体   繁体   中英

How to route sign_up in Rails 3 using Devise

I am using Devise for authenticating a Rails application. I am now able to successfully route /users/sign_in and /users/sign_out to /sign_in and /sign_out via this code in routes.rb:

devise_for :user, :as => ''

How do I map /registration/sign_up to /sign_up?

So that sign_in, sign_out, and sign_up all have the same pattern.

Note that I am using Devise only for users. No admins.

You need to add the following block to your routes.rb file:

devise_scope :user do
  get "/sign_up" => "devise/registrations#new"
end

It's explained in: http://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM