Skip to content

Commit

Permalink
Cleanup Admin::ProductsController before hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalcymerys committed Oct 30, 2023
1 parent 3edeb93 commit 5984553
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/controllers/spree/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ProductsController < ResourceController
before_action :set_product_defaults, only: :new

create.before :create_before
create.before :fix_option_values_params_rails_7_1
update.before :update_before
update.before :skip_updating_status
update.after :update_status
Expand Down Expand Up @@ -162,6 +163,12 @@ def collection
end

def create_before
return if params[:product][:prototype_id].blank?

@prototype = Spree::Prototype.find(params[:product][:prototype_id])
end

def fix_option_values_params_rails_7_1
raise 'Verify if the patch is still needed' if Rails::VERSION::STRING >= '7.2.0'

if Rails::VERSION::STRING >= '7.1.0'
Expand All @@ -180,8 +187,6 @@ def create_before
end
params[:product][:option_values_hash] = option_values_hash if option_values_hash.present?
end

@prototype = Spree::Prototype.find(params[:product][:prototype_id]) if params[:product][:prototype_id].present?
end

def update_before
Expand Down

0 comments on commit 5984553

Please sign in to comment.