Class: Spree::Admin::ServiceFeeRulesController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::ServiceFeeRulesController
- Defined in:
- app/controllers/spree/admin/service_fee_rules_controller.rb
Instance Method Summary collapse
-
#build_resource ⇒ Object
A new rule inherits the tenant you were browsing under (index's tenant dropdown).
- #index ⇒ Object
Instance Method Details
#build_resource ⇒ Object
A new rule inherits the tenant you were browsing under (index's tenant dropdown). Reading
it from the URL keeps tenant_id out of permitted_resource_params, so the form can't be
used to reassign a rule to a different tenant after the fact -- same shape as
HomepageSectionController#build_resource.
36 37 38 |
# File 'app/controllers/spree/admin/service_fee_rules_controller.rb', line 36 def build_resource model_class.new(tenant_id: params[:tenant_id].presence) end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/spree/admin/service_fee_rules_controller.rb', line 8 def index @search = model_class.ransack(params[:q]) # Same 'chip button' status filter convention as # admin/system/waiting_room_sessions#guests (see guests.html.erb) -- an unrecognized or # missing param falls back to showing everything rather than silently hiding rows. @status = %w[active inactive].include?(params[:status]) ? params[:status] : 'all' scope = @search.result scope = scope.where(active: true) if @status == 'active' scope = scope.where(active: false) if @status == 'inactive' # Same tenant-dropdown convention as admin/homepage_section#index. tenant_id only ever # gets set on a ruleable-less row (see ServiceFeeRule's tenant_id absence validation), so # picking a specific tenant narrows down to just that tenant's own default rule -- the # default (no param, "BookMe+") view shows tenant_id: nil, i.e. everything except other # tenants' own overrides: the true platform-wide default plus every product/event/vendor # rule (their tenant is already implied by their ruleable, so they never set tenant_id). scope = scope.where(tenant_id: selected_tenant&.id) @service_fee_rules = scope.order(ruleable_type: :asc, ruleable_id: :asc, currency: :asc) .page(params[:page]) .per(25) end |