Module: Spree::Admin::BaseControllerDecorator
- Defined in:
- app/controllers/spree/admin/base_controller_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#admin_oauth_token ⇒ Object
override: even in view actions, head.html.erb still need admin_oauth_token which may create new token.
-
#authorize!(*args) ⇒ Object
even db in read only mode, authorizor still need to run Warden callbacks which will write to db this include update tracked fields such as sign_in_count, last_sign_in_at, etc.
-
#invalidate_api_caches ⇒ Object
POST.
- #parse_date(date, format: nil) ⇒ Object
-
#parse_date!(date, format: nil) ⇒ Object
2023-07-31.
Class Method Details
.prepended(base) ⇒ Object
4 5 6 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 4 def self.prepended(base) base.before_action :redirect_to_billing, if: -> { Spree::Store.default.code.include?('billing') } end |
Instance Method Details
#admin_oauth_token ⇒ Object
override: even in view actions, head.html.erb still need admin_oauth_token which may create new token.
17 18 19 20 21 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 17 def admin_oauth_token ActiveRecord::Base.connected_to(role: :writing) do super end end |
#authorize!(*args) ⇒ Object
even db in read only mode, authorizor still need to run Warden callbacks which will write to db this include update tracked fields such as sign_in_count, last_sign_in_at, etc.
10 11 12 13 14 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 10 def (*args) ActiveRecord::Base.connected_to(role: :writing) do super end end |
#invalidate_api_caches ⇒ Object
POST
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 35 def invalidate_api_caches if params[:model].present? result = SpreeCmCommissioner::ApiCaches::Invalidate.call( model: params[:model], id: params[:id] ) flash[:error] = result.error if result.failure? end redirect_back fallback_location: admin_root_path end |
#parse_date(date, format: nil) ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 28 def parse_date(date, format: nil) parse_date!(date, format) rescue Date::Error nil end |
#parse_date!(date, format: nil) ⇒ Object
2023-07-31
24 25 26 |
# File 'app/controllers/spree/admin/base_controller_decorator.rb', line 24 def parse_date!(date, format: nil) Date.strptime(date.to_s, format || '%Y-%m-%d') end |