I have added a field MRP to the Product and Variants template but problem is suppose if i am updating for the second time and if MRP greater than 999 means 1000 it is getting divided by thousand and giving value as 1.00 in the field. How can i solve the issue.
class AddMrpToVariant < ActiveRecord::Migration
def self.up
add_column :spree_variants, :mrp_price, :decimal, precision: 10, scale: 2
end
def self.down
remove_column :spree_variants, :mrp_price
end
end
solved the issue by adding the following code into the model.
%w(mrp_price).each do |m|
define_method("#{m}=") do |argument|
self[m] = Spree::LocalizedNumber.parse(argument) if argument.present?
end