Rails 2.3.11
If a user tries to go to /photos when they aren't logged in, they are directed to [site]/admin/login?route=[site]/photos
. After they log in, I would like them to be sent to whatever was defined in "route" instead of the default home page.
In /app/controllers/admin_controller.rb:
def login
if session[:user_id] #already logged in
redirect_to ''
@destination = request.url
end
if request.post?
if [authentication code]
if user.activated? #check to see whether the user has activated their account
session[:user_id] = user.id
if params[:route] # ********
redirect_to "#{params[:route]}"
else
redirect_to :controller => 'home'
end
else
flash.now[:notice] = "Your account hasn't been activated yet. Check your emails!"
end
else
flash.now[:notice] = "Invalid email/password combination"
end
end
end
The "*"ed line is the one that isn't working correctly. When I check to see the parameters, :route isn't among them, so the argument isn't being passed in with the login post. Can anyone explain to me why it isn't and how I could fix it?
Thank you!
You could do something like:
session[:return_to] ||= request.referer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With