Transform weight before validation

I guess validates_length_from_database also validates numbers. That's not a bad thing.
So now it's being validated, we should validate the transformed value that will be saved to the database.
This commit is contained in:
David Cook
2023-09-21 09:48:45 +10:00
committed by Rachel Arnould
parent 9a9be8dacd
commit 117085aeba

View File

@@ -81,8 +81,8 @@ module Spree
before_validation :ensure_shipping_category
before_validation :ensure_unit_value
before_validation :update_weight_from_unit_value, if: ->(v) { v.product.present? }
before_validation :convert_variant_weight_to_decimal
before_save :convert_variant_weight_to_decimal
before_save :assign_units, if: ->(variant) {
variant.new_record? || variant.changed_attributes.keys.intersection(NAME_FIELDS).any?
}