Skip to content

Commit

Permalink
Use validated values from ProductForm
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszreszke committed Jul 29, 2024
1 parent 66aa3a0 commit 13cb420
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rails_application/app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def create
end

ActiveRecord::Base.transaction do
create_product(params[:product_id], params[:name])
if params[:price].present?
set_product_price(params[:product_id], params[:price])
create_product(product_form.product_id, product_form.name)
if product_form.price.present?
set_product_price(product_form.product_id, product_form.price)
end
if params[:vat_rate].present?
set_product_vat_rate(params[:product_id], params[:vat_rate])
if product_form.vat_rate.present?
set_product_vat_rate(product_form.product_id, product_form.vat_rate)
end
rescue ProductCatalog::AlreadyRegistered
flash[:notice] = "Product was already registered"
Expand Down

0 comments on commit 13cb420

Please sign in to comment.