mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix rubocop issue by avoiding rails method name update_attributes
This commit is contained in:
@@ -5,7 +5,7 @@ class Spree::ProductSet < ModelSet
|
||||
|
||||
def save
|
||||
@collection_hash.each_value.all? do |product_attributes|
|
||||
update_attributes(product_attributes)
|
||||
update_product_attributes(product_attributes)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,19 +18,19 @@ class Spree::ProductSet < ModelSet
|
||||
private
|
||||
|
||||
# A separate method of updating products was required due to an issue with
|
||||
# the way Rails' assign_attributes and updates_attributes behave when
|
||||
# the way Rails' assign_attributes and update behave when
|
||||
# delegated attributes of a nested object are updated via the parent object
|
||||
# (ie. price of variants). Updating such attributes by themselves did not
|
||||
# work using:
|
||||
#
|
||||
# product.update_attributes(variants_attributes: [{ id: y, price: xx.x }])
|
||||
# product.update(variants_attributes: [{ id: y, price: xx.x }])
|
||||
#
|
||||
# and so an explicit call to update attributes on each individual variant was
|
||||
# and so an explicit call to update on each individual variant was
|
||||
# required. ie:
|
||||
#
|
||||
# variant.update_attributes( { price: xx.x } )
|
||||
# variant.update( { price: xx.x } )
|
||||
#
|
||||
def update_attributes(attributes)
|
||||
def update_product_attributes(attributes)
|
||||
split_taxon_ids!(attributes)
|
||||
|
||||
product = find_model(@collection, attributes[:id])
|
||||
|
||||
Reference in New Issue
Block a user