Skip to content

Instantly share code, notes, and snippets.

@MaryKuz
Created March 28, 2019 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryKuz/6b2f672be9d29210da58c7f808e8c668 to your computer and use it in GitHub Desktop.
Save MaryKuz/6b2f672be9d29210da58c7f808e8c668 to your computer and use it in GitHub Desktop.
Adding code to ApplicationController
class ApplicationController < ActionController::Base
....
before_action :authenticate
attr_reader :current_user
private
def authenticate
authenticate_or_request_with_http_token do |token, options|
@current_user = User.joins(:auth_token).find_by(auth_tokens: { value: token })
end
end
....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment