Module: ActionSentinelGroup::Permissions
- Defined in:
- lib/action_sentinel_group/permissions.rb
Overview
Provides methods for check access permissions of a user model related to groups.
This module is designed to be included in user models that need to check access permissions. It introduces methods for checking permissions associated with a specific controller and actions.
Instance Method Summary collapse
-
#has_permission_to?(action, controller_path) ⇒ Boolean
Checks if the user has permission to perform a specific action on a controller.
Instance Method Details
#has_permission_to?(action, controller_path) ⇒ Boolean
Checks if the user has permission to perform a specific action on a controller.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/action_sentinel_group/permissions.rb', line 25 def (action, controller_path) query = AccessPermission .joins(group_table_name.singularize.to_sym => user_groups_table_name.to_sym) .where(user_groups_table_name.to_sym => { "#{user_table_name.singularize}_id".to_sym => id }) .where(controller_path: controller_path) query = if %w[sqlite sqlite3].include? self.class.connection.adapter_name.downcase query.where("actions LIKE ?", "%#{action}%") else query.where(':action = ANY("access_permissions"."actions")', action: action) end query.exists? end |