Module: Cannie::ControllerExtensions::ClassMethods
- Defined in:
- lib/cannie/controller_extensions.rb
Instance Method Summary collapse
-
#check_permissions(options = {}) ⇒ Object
Method is used to be sure, that permissions checking is handled for each action inside controller.
-
#skip_check_permissions(*args) ⇒ Object
Skip handling of permissions checking, that was defined by ‘check_permissions` method.
Instance Method Details
#check_permissions(options = {}) ⇒ Object
Method is used to be sure, that permissions checking is handled for each action inside controller.
class PostsController < ApplicationController
#...
end
19 20 21 22 23 24 25 26 |
# File 'lib/cannie/controller_extensions.rb', line 19 def (={}) after_action(.slice(:only, :except)) do |controller| next if controller.permitted? next if [:if] && !controller.instance_eval([:if]) next if [:unless] && controller.instance_eval([:unless]) raise CheckPermissionsNotPerformed, 'Action failed the check_permissions because it does not calls permit! method. Add skip_check_permissions to bypass this check.' end end |
#skip_check_permissions(*args) ⇒ Object
Skip handling of permissions checking, that was defined by ‘check_permissions` method
class PostsController < ApplicationController
#...
end
35 36 37 38 39 |
# File 'lib/cannie/controller_extensions.rb', line 35 def (*args) before_action(*args) do |controller| controller.instance_variable_set(:@_permitted, true) end end |