app/controllers/application_controller.rb
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception.
For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception . For APIs you may want to use : null_session instead .
def current_user
    @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
    @current_user ||= User.find_by_authentication_token(cookies[:auth_token]) if cookies[:auth_token] && @current_user.nil?
    @current_user
  end
def current_user @current_user ||= User . find_by_id ( session [ :user_id ] ) if session [ :user_id ] @current_user ||= User . find_by_authentication_token ( cookies [ :auth_token ] ) if cookies [ :auth_token ] && @current_user . nil? @current_user end
Prevent CSRF attacks by raising an exception.
Prevent CSRF attacks by raising an exception .
# Note: we want to use "find_by_id" because it's OK to return a nil. # If we were to use User.find, it would throw an exception if the user can't be found.