Skip to content

Instantly share code, notes, and snippets.

@ssoulless
Last active June 25, 2016 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssoulless/8e5a49405988ed34036909b07560b34b to your computer and use it in GitHub Desktop.
Save ssoulless/8e5a49405988ed34036909b07560b34b to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
before_action :store_location
protect_from_forgery with: :exception
def store_location
# store last url as long as it isn't a /users path
session[:previous_url] = request.referer unless request.fullpath =~ /\/users/
end
def after_sign_in_path_for(resource)
session[:previous_url] || root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment