如何将设计登录页面设置为Rails中的根页面 [英] How to set devise sign in page as root page in rails
问题描述
我有一个设计个性。
我想将设计个性的登录页面设置为我项目的根页面。
I would like to set the sign in page for the devise personality as the root page for my project.
我应该对 routes.rb
进行哪些更改?
What changes should I make in the routes.rb
?
Rails版本:3.2.14
Rails version : 3.2.14
耙路为我提供了以下root权限
rake routes gives me the following for root
root / devise/sessions#new
但我还是得到了欢迎的Rails页面。 (localhost:3000)
but still i get the welcome aboard rails page. (localhost:3000)
推荐答案
将此添加到路由中。rb
Add this to your routes.rb
devise_scope :user do
root :to => 'devise/sessions#new'
end
但是在登录后执行此操作可能会陷入无限循环错误,因此最好通过覆盖devise方法在应用程序控制器中登录后和退出后添加路径
but on doing this, after sign in you might get stuck in infinite loop error, so its better to add after sign in and after sign out path in your application controller by overriding the devise methods
def after_sign_in_path_for(resource_or_scope)
# your_path
end
def after_sign_out_path_for(resource_or_scope)
# your_path
end
这将起作用!
这篇关于如何将设计登录页面设置为Rails中的根页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!