Class: SolidusFriendlyPromotions::Admin::PromotionsController
- Inherits:
-
BaseController
- Object
- Spree::Admin::ResourceController
- BaseController
- SolidusFriendlyPromotions::Admin::PromotionsController
- Defined in:
- app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
#collection_url, #edit_object_url, #new_object_url, #object_url, #parent, #parent_model_name, #routes_proxy
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb', line 12 def create @promotion = model_class.new(permitted_resource_params) @promotion.codes.new(value: params[:single_code]) if params[:single_code].present? if params[:code_batch] @code_batch = @promotion.code_batches.new(code_batch_params) end if @promotion.save @code_batch&.process flash[:success] = t("solidus_friendly_promotions.promotion_successfully_created") redirect_to location_after_save else flash[:error] = @promotion.errors..to_sentence render action: "new" end end |