Created
October 9, 2015 23:08
-
-
Save rjswenson/9e8519f3228130629622 to your computer and use it in GitHub Desktop.
Change Mongoid object w/o callbacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
Document.where(:wholesale_price_group.ne => nil, :total_prices.ne => {}).each do |doc| | |
wsl = doc.total_prices[doc.wholesale_price_group] | |
Document.collection.where({_id: doc.id}).update({ | |
"$set" => { :wholesale_total => wsl } | |
}) | |
end |
Author
rjswenson
commented
Oct 20, 2015
[array of document numbers].each do |num|
doc = Document.where(number: num).first
if /-05$/ =~ doc.customer
doc.submit_backend
else
Document.collection.where({_id: doc.id}).update({
"$set" => {:customer => doc.customer + "-05"} })
doc.pages.each do |page|
page.customer_number = page.customer_number + "-05"
page.save
end
doc.submit_backend
end
end
DOZUSENO | OR04
BIJOHOTSUJI | SO12
SEGOPITA | ZO02-05
BIKACHIDEDO | ZO02-05
SEKUDUGE | OU47-05
BEHEBUJIFU | OU41-05
BESUHANEPI | SO12-05
BIMIDOCHIMU| SO13-05
BETZUTOGIYO | CA29
BIMUKEMIJO | ZO02
FUKOYOHI | OU41
GUSETEHO | SO13
BIMEDABEMO | KU06 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment