When a user logs in, they automatically get routed to the /user page for example. How can I have them directed to the main homepage (home.htm.erb) after logging in?
Asked
Active
Viewed 1,291 times
0
-
see http://stackoverflow.com/questions/8640326/redirect-user-after-log-in-only-if-its-on-root-path – jazzytomato Mar 03 '13 at 00:31
-
this actually depends on your code. are you using some sort of authentication gem like devise or omniauth? or did you roll out your own? you need to include those details in your question. – jvnill Mar 03 '13 at 03:11
2 Answers
0
I'm assuming you have a Sessions object you're creating? In the sessions#create action
redirect_to root_url
Richard Brown
- 11,346
- 4
- 32
- 43
0
Depending on your gem for authentication
In your 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
Jackie Chan
- 2,654
- 6
- 35
- 70