Class: SolidusFriendlyPromotions::Admin::BenefitsController
- Inherits:
-
Spree::Admin::BaseController
- Object
- Spree::Admin::BaseController
- SolidusFriendlyPromotions::Admin::BenefitsController
- Defined in:
- app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb', line 14 def create @benefit = @benefit_type.new(benefit_params) @benefit.promotion = @promotion if @benefit.save(validate: false) flash[:success] = t("spree.successfully_created", resource: SolidusFriendlyPromotions::Benefit.model_name.human) redirect_to location_after_save, format: :html else render :new, layout: false end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb', line 46 def destroy @benefit = @promotion.benefits.find(params[:id]) if @benefit.destroy flash[:success] = t("spree.successfully_removed", resource: SolidusFriendlyPromotions::Benefit.model_name.human) end redirect_to location_after_save, format: :html end |
#edit ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb', line 26 def edit @benefit = @promotion.benefits.find(params[:id]) if params.dig(:benefit, :calculator_type) @benefit.calculator_type = params[:benefit][:calculator_type] end render layout: false end |
#new ⇒ Object
9 10 11 12 |
# File 'app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb', line 9 def new @benefit = @promotion.benefits.build(benefit_params) render layout: false end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb', line 34 def update @benefit = @promotion.benefits.find(params[:id]) @benefit.assign_attributes(benefit_params) if @benefit.save flash[:success] = t("spree.successfully_updated", resource: SolidusFriendlyPromotions::Benefit.model_name.human) redirect_to location_after_save, format: :html else render :edit end end |