2013-03-03 99 views
0

当用户登录时,它们会自动路由到/ user页面。 如何在登录后将它们定向到主页(home.htm.erb)?如何在登录后重定向用户? (Ruby on Rails)

+0

看到http://stackoverflow.com/questions/8640326/redirect -user-after-log-in-only-if-its-on-root-path – jazzytomato 2013-03-03 00:31:21

+0

这实际上取决于你的代码。你是否使用某种形式的验证宝石像devise或omniauth?还是你推出自己的?你需要在你的问题中包含这些细节。 – jvnill 2013-03-03 03:11:15

回答

0

我假设你有一个Sessions对象,你正在创建?在sessions#create行动

redirect_to root_url 
0

根据您的宝石认证

在你的app/controllers/application_controller.rb

 
class ApplicationController 'new', :controller => 'sessions', :only_path => false, :protocol => 'http') 
    if request.referer == sign_in_url 
     super 
    else 
     stored_location_for(resource) || request.referer || root_path 
    end 
    end 
end