Martin S.
unread,Jul 8, 2010, 5:22:54 AM7/8/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Devise
Hi!
I wanted devise to use short routes for sign_in, sign_up and sign_out.
I found a few mentions in this group, but no solution. So after
reading some source, here's mine:
devise_for :user, :path => 'account', :skip =>
[:sessions, :registration] do
scope :controller => 'devise/sessions', :as => :user_session do
get :new, :path => 'signin'
post :create, :path => 'signin', :as => ""
get :destroy, :path => 'signout'
end
resource :registration, :only => [:edit, :update, :destroy], :as
=> :user_registration,
:path => 'account', :controller => 'devise/registrations'
scope :controller => 'devise/registrations', :as
=> :user_registration do
get :new, :path => 'signup', :as => "new"
post :create, :path => 'signup', :as => ""
end
end
This generates the following routes:
new_user_session GET /signin(.:format)
{:action=>"new", :controller=>"devise/sessions"}
user_session POST /signin(.:format)
{:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /signout(.:format)
{:action=>"destroy", :controller=>"devise/sessions"}
PUT /account(.:format)
{:action=>"update", :controller=>"devise/registrations"}
DELETE /account(.:format)
{:action=>"destroy", :controller=>"devise/registrations"}
edit_user_registration GET /account/edit(.:format)
{:action=>"edit", :controller=>"devise/registrations"}
new_user_registration GET /signup(.:format)
{:action=>"new", :controller=>"devise/registrations"}
user_registration POST /signup(.:format)
{:action=>"create", :controller=>"devise/registrations"}
POST /account/password(.:format)
{:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /account/password/new(.:format)
{:action=>"new", :controller=>"devise/passwords"}
user_password PUT /account/password(.:format)
{:action=>"update", :controller=>"devise/passwords"}
edit_user_password GET /account/password/edit(.:format)
{:action=>"edit", :controller=>"devise/passwords"}
POST /account/confirmation(.:format)
{:action=>"create", :controller=>"devise/confirmations"}
new_user_confirmation GET /account/confirmation/new(.:format)
{:action=>"new", :controller=>"devise/confirmations"}
user_confirmation GET /account/confirmation(.:format)
{:action=>"show", :controller=>"devise/confirmations"}
Cheers,
Martin