Skip to content

Instantly share code, notes, and snippets.

@andreas-it-dev
Created December 22, 2016 20:43
Show Gist options
  • Save andreas-it-dev/28baeaf90c77b7914b23cba4eebb6188 to your computer and use it in GitHub Desktop.
Save andreas-it-dev/28baeaf90c77b7914b23cba4eebb6188 to your computer and use it in GitHub Desktop.
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
..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