Skip to content

Instantly share code, notes, and snippets.

@pottedmeat7
Last active October 24, 2017 20:53
Show Gist options
  • Save pottedmeat7/383029b0b3cc8271660230817114ca13 to your computer and use it in GitHub Desktop.
Save pottedmeat7/383029b0b3cc8271660230817114ca13 to your computer and use it in GitHub Desktop.
before_filter :store_location
def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited.
return unless request.get?
if ( !request.path.include?("/log-in") &&
!request.path.include?("/users/confirmation") &&
!request.path.include?("/users/password/new") &&
!request.path.include?("/users/password/edit") &&
!request.xhr?) # don't store ajax calls
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