module StorePath

Public Instance Methods

restore_previous_path() click to toggle source
# File lib/store_path.rb, line 18
def restore_previous_path
  if session[:previous_path]
    redirect_to session[:previous_path]
  else
    redirect_to :controller => session[:previous_controller], :action => session[:previous_action]
  end
end
store_current_path( args = nil ) click to toggle source
# File lib/store_path.rb, line 3
def store_current_path( args = nil )
  if args.nil?
    set_default
  else
    if args[:path]
      args[:path] = args[:path] + "/" if args[:path][-1] != "/"
      args[:path] = args[:path].insert( 0, "/" ) if args[:path][0] != "/"
      session[:previous_path] = args[:path]
    elsif args[:controller] and args[:action]
      session[:previous_controller] = args[:controller]
      session[:previous_action] = args[:action]
    end
  end
end

Private Instance Methods

set_default() click to toggle source
# File lib/store_path.rb, line 28
def set_default
  session[:previous_path] = request.fullpath
end