The default root page of my app needs to be the login page.
If I do this (as suggested in this question):
root :to => "devise/sessions#new
I get:
Started GET "/" for 127.0.0.1 at 2011-04-06 10:36:38 +0200
Processing by Devise::SessionsController#new as HTML
Completed in 0ms
AbstractController::ActionNotFound (AbstractController::ActionNotFound):
I've also tried to overwrite the Devise::SessionsController
开发者_开发百科 to look like this:
class SessionsController < Devise::SessionsController
def new
end
end
In routes I have:
devise_for :users, :controllers => {:sessions => "sessions"}
EDIT rake routes
show:
...
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"sessions"}
root /(.:format) {:controller=>"devise/sessions", :action=>"new"}
...
Using devise 1.1.7 with Rails 3.
Do you need that the login page is the default even if the user is already logged in?
If thats not the case you can just point to some controller.
In your routes:
map.root :controller => :your_controller
And then require that the user is authenticated: In your_controller:
before_filter :authenticate_user!
That will redirect the user to the login form except if he/she is already logged in.
精彩评论