Commit 9a93a645 by Truong Ba Dieu

Fix recalculate order

parent 181deb8b
...@@ -10,7 +10,7 @@ class Order < ActiveRecord::Base ...@@ -10,7 +10,7 @@ class Order < ActiveRecord::Base
count = line_items.sum(:quantity) count = line_items.sum(:quantity)
self.update_columns( self.update_columns(
item_count: count, item_count: count,
item_total: line_items.inject(0) {|sum, item| sum + item.quantity*item.price } item_total: self.reload.line_items.inject(0) {|sum, item| sum + item.quantity*item.price }
) )
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment