Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 登录后如何重定向用户?(Ruby on Rails)_Ruby On Rails_Ruby On Rails 3_Html - Fatal编程技术网

Ruby on rails 登录后如何重定向用户?(Ruby on Rails)

Ruby on rails 登录后如何重定向用户?(Ruby on Rails),ruby-on-rails,ruby-on-rails-3,html,Ruby On Rails,Ruby On Rails 3,Html,例如,当用户登录时,他们会自动路由到/user页面。 登录后如何将它们定向到主主页(home.htm.erb?我假设您有一个正在创建的会话对象?在会话中#创建操作 redirect_to root_url 根据您的gem进行身份验证 在应用程序/controllers/application_controller.rb中 class ApplicationController 'new', :controller => 'sessions', :only_path => false, :pr

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

我假设您有一个正在创建的会话对象?在
会话中#创建
操作

redirect_to root_url

根据您的gem进行身份验证

在应用程序/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 类ApplicationController'new',:controller=>'sessions',:only_path=>false,:protocol=>'http') 如果request.referer==在url中签名 超级的 其他的 (资源)| | request.referer | |根路径的存储位置| 结束 结束 结束
看,这实际上取决于你的代码。您是否正在使用Desive或omniauth之类的身份验证gem?还是你推出了自己的?你需要在你的问题中包括这些细节。