Skip to content

Instantly share code, notes, and snippets.

@kidpollo
Created June 5, 2013 21:59
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 kidpollo/5717664 to your computer and use it in GitHub Desktop.
Save kidpollo/5717664 to your computer and use it in GitHub Desktop.
module V1
class BaseController < ApplicationController
include V1::ResponseMetaData
include V1::ErrorHandling
include V1::ReadOnly
include Pundit
rescue_from Pundit::NotAuthorizedError, with: :render_401
rescue_from ActiveRecord::RecordInvalid, :with => :render_422
def warden
env['warden']
end
def current_consumer
@current_consumer ||= (warden.authenticate! scope: current_community)
end
helper_method :current_consumer
def current_scope
@current_scope ||= begin
current_consumer.scope
end
end
helper_method :current_scope
def current_user
current_consumer.user
end
helper_method :current_user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment