Files

Merb::AuthenticatedHelper

Public Instance Methods

redirect_back_or(default_url, opts = {}) click to toggle source

Add a helper to do the redirect_back_or for you. Also tidies up the session afterwards If there has been a failed login attempt on some page using this method you’ll be redirected back to that page. Otherwise redirect to the default_url

To make sure you’re not redirected back to the login page after a failed then successful login, you can include an ignore url. Basically, if the return url == the ignore url go to the default_url

set the ignore url via an :ignore option in the opts hash.

# File lib/merb-auth-more/mixins/redirect_back.rb, line 27
def redirect_back_or(default_url, opts = {})
  if !session[:return_to].blank? && ![opts[:ignore]].flatten.include?(session[:return_to].first)
    redirect session[:return_to].first, opts
    session[:return_to] = nil
  else
    redirect default_url, opts
  end
  "Redirecting to <a href='#{default_url}'>#{default_url}</a>"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.