Basically Im running a rake task to update the "notes" field in my rails 3 app. Currently I have my task set up as follows:
desc "Update notes"
task :get_notes => :environment do
Product.find(:all, :conditions => ["categories like ?", "%" + '123456' + "%"]).each do |product|
old_note = product.notes
notes = old_note + ", <new note>"
product.update_attribute(:notes, notes)
end
The problem is I have about 250 unique categories to update with 250 unique notes, so I've basically just copied this over 250 times in my task. How can I more efficiently accomplish this? (This is just a one time thing, but I would like to know how to better do it for future issues such as this).