def ensure_permission!(action=nil, &block)
      unless action
        klass = self.class.name.underscore.sub("_controller", "")
        action = "#{klass}##{action_name}"
      end

      # If the action doesn't exist, don't worry about the current_user
      if Action.where(name: action).count == 0
        maybe_render(true, block)
      else
        has_something?(:has_permission?, action, block)
      end
    end
def ensure_permission!(action=nil, &block)
      unless action
        klass = self.class.name.underscore.sub("_controller", "")
        action = "#{klass}##{action_name}"
      end

      # If the action doesn't exist, don't worry about the current_user
      if Action.where(name: action).count == 0
        maybe_render(true, block)
      else
        has_something?(:has_permission?, action, block)
      end
    end
Ensure that `current_user` has permission to a given action. If no action
 name is supplied, this will instead use the currently-executing controller
 and action names. If no block is given, a failed check will render a
 header-only response with status code 403 (Forbidden).

 @param [String] action name of the action to check permissions for.
 @param [Proc] block if given, invoked with a single parameter, which is
   the result of the role check.