mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Use #dup when copying attributes hash
In Rails 4, #clone behaves differently. The attributes hash of the cloned object is shared with the original, it's not a separate object! https://github.com/rails/rails/blob/4-0-stable/activerecord/lib/active_record/core.rb#L217-L220
This commit is contained in:
@@ -9,7 +9,7 @@ class UserDefaultAddressSetter
|
||||
|
||||
# Sets the order bill address as the user default bill address
|
||||
def set_default_bill_address
|
||||
new_bill_address = @order.bill_address.clone.attributes
|
||||
new_bill_address = @order.bill_address.dup.attributes
|
||||
|
||||
set_bill_address_attributes(@current_user, new_bill_address)
|
||||
set_bill_address_attributes(@order.customer, new_bill_address)
|
||||
@@ -17,7 +17,7 @@ class UserDefaultAddressSetter
|
||||
|
||||
# Sets the order ship address as the user default ship address
|
||||
def set_default_ship_address
|
||||
new_ship_address = @order.ship_address.clone.attributes
|
||||
new_ship_address = @order.ship_address.dup.attributes
|
||||
|
||||
set_ship_address_attributes(@current_user, new_ship_address)
|
||||
set_ship_address_attributes(@order.customer, new_ship_address)
|
||||
|
||||
Reference in New Issue
Block a user