Created
October 28, 2014 01:34
-
-
Save leostera/7ddd4355f78861738096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# Prevent CSRF attacks by raising an exception. | |
# For APIs, you may want to use :null_session instead. | |
protect_from_forgery with: :exception | |
helper_method :current_user | |
alias_method :devise_current_user, :current_user | |
def current_user | |
@current_user ||= if session[:user_id] | |
User.find(session[:user_id]) | |
else | |
devise_current_user | |
end | |
end | |
def after_sign_in_path_for(resource) | |
session[:previous_url] || home_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment