Notes posted by pkondzior

RSS feed
October 1, 2009
0 thanks

This code prevent's frome redirect_to(:back) looping

Prevent redirect_to(:back) looop

begin

# loop check
if session[:last_back] != request.env['HTTP_REFERER']
  redirect_to(:back)
  session[:last_back] = request.env['HTTP_REFERER']
else
  # raise on error
  raise ActionController::RedirectBackError
end

rescue ActionController::RedirectBackError

# fallback on loop or other :back error
redirect_to(:action => :index)

end