Hi there
I have a model that needs to get an extra field. So, I created a migration
to add the field
add_column :my_models, :my_field, :string
This works fine as per usual. However, I want to populate the field with a
value so I do this
MyModel.find(:all).each do |m|
m.my_field = "value"
puts m.my_field
puts m.save
m.reload
puts m.my_field
end
lower in the self.up part of the migration.
When I run the migration I get this output:
"value"
true
nil
I have confirmed that the field is populated in a before_filter by
outputting the field value before it is saved. I have also confirmed that
the ''my_field'' field value is "value" in def
after_save but, if I find an
instance of MyModel from the db, I get my_field = nil.
Any ideas?
Ivor
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---