Module: Blazer::BaseControllerDecorator
- Defined in:
- app/controllers/blazer/base_controller_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #restrict_organizer_access ⇒ Object
-
#set_writing_role(&block) ⇒ Object
Annonymous block: www.rubydoc.info/gems/rubocop/RuboCop/Cop/Naming/BlockForwarding.
Class Method Details
.prepended(base) ⇒ Object
4 5 6 7 |
# File 'app/controllers/blazer/base_controller_decorator.rb', line 4 def self.prepended(base) base.around_action :set_writing_role base.before_action :restrict_organizer_access end |
Instance Method Details
#restrict_organizer_access ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/blazer/base_controller_decorator.rb', line 14 def restrict_organizer_access return unless spree_current_user.organizer? && !spree_current_user.admin? return if controller_name == 'queries' && %w[show run].include?(action_name) raise ActionController::RoutingError, 'Unauthorized' end |
#set_writing_role(&block) ⇒ Object
Annonymous block: www.rubydoc.info/gems/rubocop/RuboCop/Cop/Naming/BlockForwarding
10 11 12 |
# File 'app/controllers/blazer/base_controller_decorator.rb', line 10 def set_writing_role(&block) ActiveRecord::Base.connected_to(role: :writing, &block) end |