Skip to content

Instantly share code, notes, and snippets.

@sevenseacat
Last active December 27, 2015 01:18
Show Gist options
  • Save sevenseacat/7243517 to your computer and use it in GitHub Desktop.
Save sevenseacat/7243517 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
# Overwrite Devise's authenticate_user! to store where they should be redirected back to
def authenticate_user!(opts={})
session[:user_return_to] = request.referrer
super(opts)
end
# Change redirect after Devise login; defaults to root_url
def after_sign_in_path_for(user)
stored_location_for(user) || dashboard_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment