09 Oct 2012, 11:40
Generic-user-small

Alex Boiko (1 post)

have two migrations one: class AddPriceToLineItems < ActiveRecord::Migration def change add_column :line_items, :price, :decimal, default: 0, precision: 8, scale: 2 end end

two: class CopyProductIdToLineItem < ActiveRecord::Migration def up Cart.all.each do |cart| cart.line_items.each do |item| item.price = item.product.price say item.product.title say item.quantity say item.price end end end def down end end

After migrating price of the line_items in cart equals 0 ( default value ) But while migration say gives item.price = correct values Looks like it becomes 0 later

  You must be logged in to comment