app/controllers/api/v1x0/actions_controller.rb
# Different roles can only create certain kind of actions
#   admin:     can create all kinds of actions
#   approver:  can not create 'cancel' action
#   requester: can only create 'cancel' action
Different roles can only create certain kind of actions
admin:     can create all kinds of actions
approver:  can not create 'cancel' action
requester: can only create 'cancel' action
Different roles can only create certain kind of actions admin : can create all kinds of actions approver : can not create ' cancel ' action requester : can only create ' cancel ' action
def validate_create_action
        operation = params[:operation]
        valid_operation = admin? || (approver? && operation != Action::CANCEL_OPERATION) || (!admin? && !approver? && operation == Action::CANCEL_OPERATION)
        raise Exceptions::NotAuthorizedError, "Not authorized to create [#{operation}] action " unless valid_operation
      end
def validate_create_action operation = params [ :operation ] valid_operation = admin? || ( approver? && operation != Action :: CANCEL_OPERATION ) || ( ! admin? && ! approver? && operation == Action :: CANCEL_OPERATION ) raise Exceptions :: NotAuthorizedError , "Not authorized to create [#{operation}] action " unless valid_operation end
Different roles can only create certain kind of actions
admin:     can create all kinds of actions
approver:  can not create 'cancel' action
requester: can only create 'cancel' action
Different roles can only create certain kind of actions admin : can create all kinds of actions approver : can not create ' cancel ' action requester : can only create ' cancel ' action