Skip to content

Instantly share code, notes, and snippets.

@aypn0s
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save aypn0s/7d4ad783170b293a75bb to your computer and use it in GitHub Desktop.

Select an option

Save aypn0s/7d4ad783170b293a75bb to your computer and use it in GitHub Desktop.
Devise store session
# Application controller
before_action :store_location
def store_location
if request.path != '/users/sign_in' &&
request.path != '/users/sign_up' &&
request.path != '/users/password/new' &&
request.path != '/users/password/edit' &&
!request.xhr? && !request.post? && !request.put?
session[:previous_url] = request.fullpath
end
end
def after_sign_in_path_for(resource)
session[:previous_url] || root_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment