I\'m trying to set up a sign in form on my home page. I managed to do it by following the Wiki
Except, if the login infos are incorrect, the /devise/session/new.ht
If you're running into the error undefined method 'users_url' for #
when overriding the devise sessions controller you can provide a path name as below. The important addition that you missed is the , :as => :users
.
devise_scope :user do
root :to => "devise/sessions#new", :as => :users
get "sign_in", :to => "devise/sessions#new"
get "sign_out", :to => "devise/sessions#destroy"
get "sign_up", :to => "devise/registrations#new"
end
The above route name might conflict with existing or future routes. As an alternative, I have found that this setup tends to work well:
devise_for :users,
:path_names => { :sign_out => 'logout',
:sign_in => 'login',
:sign_up => 'register' },
:controllers => { :sessions => 'users/sessions' } do
# Sessions
post '/login' => 'users/sessions#create', :as => :user_session
get '/login' => 'users/sessions#new', :as => :new_user_session
get '/logout' => 'users/sessions#destroy', :as => :destroy_user_session
# Passwords
post '/password' => 'devise/passwords#create', :as => :user_password
put '/password' => 'devise/passwords#update'
get '/password/new' => 'devise/passwords#new', :as => :new_user_password
get '/password/edit' => 'devise/passwords#edit', :as => :edit_user_password
# Registrations
post '/register' => 'devise/registrations#create', :as => :user_registration
get '/register' => 'devise/registrations#new', :as => :new_user_registration
get '/account' => 'devise/registrations#edit', :as => :edit_user_registration
put '/account' => 'devise/registrations#update'
delete '/account' => 'devise/registrations#destroy'
end