Commit 118f69e4 by Ivan Lan

Fix Order :incr_snapshot_ids

parent 77d31461
...@@ -148,13 +148,21 @@ module Shotengai ...@@ -148,13 +148,21 @@ module Shotengai
end end
# into order # into order
def incr_snapshot_ids= ids # def incr_snapshot_ids= ids
ActiveRecord::Base.transaction do # ActiveRecord::Base.transaction do
ids.each { |id| # ids.each { |id|
# using update(shotengai_order_id: id) can not get self.id before save # # using update(shotengai_order_id: id) can not get self.id before save
Shotengai::Snapshot.find(id).update!(shotengai_order: self) # Shotengai::Snapshot.find(id).update!(shotengai_order: self)
} # }
end # end
# end
attr_accessor :incr_snapshot_ids
after_save(if: :incr_snapshot_ids) do
Array(incr_snapshot_ids).each { |id|
Shotengai::Snapshot.find(id).update!(shotengai_order: self)
}
end end
# back to cart # back to cart
......
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