Since they removed redirect_back_or_default in Rails 2.0, and I still had a need to do something like that, I made method you can put under the private portion of your ApplicationController:
def redirect_back_or(path)
redirect_to :back
rescue ActionController::RedirectBackError
redirect_to path
end
and you use it just like the redirect_back_or_default method.
Subscribe to:
Post Comments (Atom)
4 comments:
Thanks this was just what I was looking for.
Perfect. it is what I searching for.
This link says it was never a part of rails, but lib/login_system.rb instead.
http://www.ruby-forum.com/topic/3081
yeeh it's true
and this is the code of that method
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end
thanks any way and you code is good also
Post a Comment