Eric Gross wrote:
so whats the best way to handle a login controller that uses a before
filter to catches users who arent logged in.
How do you enable the user to go to the page they were trying to get to?
Ive been having problems with request.env["HTTP_REFERER"] as well
When I have a complex url like /books?id=5&c=4
then it works, but if it is simple like
/books, it doesnt work correctly. Anyone figure this out?
I do this by having a before_filter on the protected page that stores
the path of that page in a session variable, using request.path:
session[:requested_page] = request.path
flash[:notice] = "Please log in first."
redirect_to(:controller => 'login')
Then when they log in successfully, you can just do
It's handled every URL I've thrown at it so far! It also feels a bit
more reliable than trusting the HTTP_REFERER environment variable.