Skip to content

Commit

Permalink
Merge pull request #6023 from solidusio/backport/v4.4/pr-5981
Browse files Browse the repository at this point in the history
[v4.4] Fix(promotions): Validate benefits on save
  • Loading branch information
tvdeyen authored Dec 6, 2024
2 parents 816bc66 + 3683320 commit 2f82f59
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def new
def create
@benefit = @benefit_type.new(benefit_params)
@benefit.promotion = @promotion
if @benefit.save(validate: false)
if @benefit.save
flash[:success] =
t("spree.successfully_created", resource: SolidusPromotions::Benefit.model_name.human)
redirect_to location_after_save, format: :html
else
render :new, layout: false
render :new, layout: false, status: :unprocessable_entity
end
end

Expand All @@ -28,7 +28,7 @@ def edit
if params.dig(:benefit, :calculator_type)
@benefit.calculator_type = params[:benefit][:calculator_type]
end
render layout: false
render layout: false, status: :unprocessable_entity
end

def update
Expand All @@ -39,7 +39,7 @@ def update
t("spree.successfully_updated", resource: SolidusPromotions::Benefit.model_name.human)
redirect_to location_after_save, format: :html
else
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down

0 comments on commit 2f82f59

Please sign in to comment.