Created
December 22, 2016 20:43
-
-
Save andreas-it-dev/28baeaf90c77b7914b23cba4eebb6188 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 | |
protect_from_forgery with: :exception | |
before_action :require_signin | |
private | |
def require_signin | |
unless current_user | |
redirect_to new_session_url, alert: 'Please sign in first!' | |
end | |
end | |
def current_user | |
@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
end | |
end |
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
..DEPRECATION WARNING: You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`. (called from current_user at /home/andreas/railsdev/dai-ditno/app/controllers/application_controller.rb:14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment