Skip to content

Commit a51b34a

Browse files
authored
Fix warning in Ch08 - Validate quantity of products (#60)
1 parent dad202f commit a51b34a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

rails6/en/chapter08-improve-orders.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class EnoughProductsValidator < ActiveModel::Validator
383383
record.placements.each do |placement|
384384
product = placement.product
385385
if placement.quantity > product.quantity
386-
record.errors[product.title.to_s] << "Is out of stock, just #{product.quantity} left"
386+
record.errors.add product.title, "Is out of stock, just #{product.quantity} left"
387387
end
388388
end
389389
end

rails6/es/chapter08-improve-orders.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class EnoughProductsValidator < ActiveModel::Validator
382382
record.placements.each do |placement|
383383
product = placement.product
384384
if placement.quantity > product.quantity
385-
record.errors[product.title.to_s] << "Is out of stock, just #{product.quantity} left"
385+
record.errors.add product.title, "Is out of stock, just #{product.quantity} left"
386386
end
387387
end
388388
end

rails6/fr/chapter08-improve-orders.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class EnoughProductsValidator < ActiveModel::Validator
378378
record.placements.each do |placement|
379379
product = placement.product
380380
if placement.quantity > product.quantity
381-
record.errors[product.title.to_s] << "Is out of stock, just #{product.quantity} left"
381+
record.errors.add product.title, "Is out of stock, just #{product.quantity} left"
382382
end
383383
end
384384
end

0 commit comments

Comments
 (0)