Sha256: 304b3bd9214f780bbbf06cc8789f7bdf1ea4f1a0c645b4669e2a7d62a0b8534c
Contents?: true
Size: 1.32 KB
Versions: 35
Compression:
Stored size: 1.32 KB
Contents
class MigrateDonationTypes < ActiveRecord::Migration def update_action_and_order(action, new_subtype, payment_method=nil) puts "Fixing Action #{action.id} -----------------------------------------" puts "Old subtype #{action.subtype}" puts "New subtype #{new_subtype}" action.subtype = new_subtype saved = action.save puts "Saved #{saved}" if action.subject.nil? puts "No order found" elsif payment_method.nil? puts "No change to payment method" else puts "Fixing Order #{action.subject.id}" puts "Old payment method #{action.subject.payment_method}" puts "New payment method #{payment_method}" action.subject.payment_method = payment_method saved = action.subject.save puts "Saved #{saved}" end end def change Action.where(:subtype => 'Donation').each do |action| update_action_and_order(action, "Monetary") end Action.where(:subtype => 'Donation (Cash)').each do |action| update_action_and_order(action, "Monetary", "Cash") end Action.where(:subtype => 'Donation (Check)').each do |action| update_action_and_order(action, "Monetary", "Check") end Action.where(:subtype => 'Donation (In-Kind)').each do |action| update_action_and_order(action, "In-Kind", "Other") end end end
Version data entries
35 entries across 35 versions & 1 rubygems