I am struggling with rails and db:migrate. I have a migration with this code
class SetDefaultInstallmentsForLicenses < ActiveRecord::Migration
def up
License.where(code: 'LEADER').each do |leader|
puts "Modifying license #{leader.id} with code #{leader.code}"
leader.installment_available = true
leader.installment_number = 5
leader.save
puts "After save #{leader.installment_available} #{leader.installment_number}"
leader = License.find(leader.id)
puts "After save #{leader.installment_available} #{leader.installment_number}"
end
end
def down
end
end
After running the migration there is this output
== SetDefaultInstallmentsForLicenses: migrating ==============================
Modifying license 3 with code LEADER
After save true 5
After save f
== SetDefaultInstallmentsForLicenses: migrated (0.0037s) =====================
It's clearly visible that the migration was executed, record was found, changed and saved, but after reloading the record, the changes are not there. What's wrong?