Ruby on rails 如何使用Desive将Rails默认根目录映射到登录页面?
我的应用程序的默认根页面必须是登录页面 如果我这样做(如中所建议): 我得到:Ruby on rails 如何使用Desive将Rails默认根目录映射到登录页面?,ruby-on-rails,login,devise,root,Ruby On Rails,Login,Devise,Root,我的应用程序的默认根页面必须是登录页面 如果我这样做(如中所建议): 我得到: 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): 我还尝试
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):
我还尝试覆盖designe::sessioncontroller
,如下所示:
class SessionsController < Devise::SessionsController
def new
end
end
编辑rake路由
显示:
...
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"}
...
将Desive 1.1.7与导轨3一起使用 即使用户已经登录,您也需要默认登录页面吗 如果不是这样,你可以指向某个控制器 在您的路线中:
map.root :controller => :your_controller
然后要求对用户进行身份验证:
在您的控制器中:
before_filter :authenticate_user!
这会将用户重定向到登录表单,除非他/她已经登录。您能向我们展示您的
rake routes
输出吗?在我的问题中添加了rake routes
的相关部分。
map.root :controller => :your_controller
before_filter :authenticate_user!