Module: Trax::Controller::Authorization::Pundit::Adapter

Extended by:
ActiveSupport::Concern
Includes:
Pundit
Defined in:
lib/trax/controller/authorization/pundit/adapter.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authorization_action_for(action_name) ⇒ Object

not included into controller



26
27
28
# File 'lib/trax/controller/authorization/pundit/adapter.rb', line 26

def self.authorization_action_for(action_name)
  "::Trax::Controller::Authorization::Pundit::Actions::#{action_name.to_s.camelize}".safe_constantize
end

Instance Method Details

#policy(record) ⇒ Object



21
22
23
# File 'lib/trax/controller/authorization/pundit/adapter.rb', line 21

def policy(record)
  self.class._policy_class.new(current_user, record)
end

#render_pundit_errorsObject



17
18
19
# File 'lib/trax/controller/authorization/pundit/adapter.rb', line 17

def render_pundit_errors
  render_errors(:forbidden, error_messages_hash: { :not_authorized => 'You are not authorized to perform this action' } )
end