Flowdock

Notes posted by GreggPollack

RSS feed
June 22, 2008
4 thanks

update_on and update_at only set on attribute change

If you call save, and no attributes are “dirty” (changed), then an update query will not happen against the database, and thus updated_at and updated_on will not be set.

You’ll need to modify at least one field to get updated_at and updated_on to set themselves.

June 22, 2008
9 thanks

Bang methods also need will_change!

As it says here at the bottom if you do in-place modifications using << you’ll need to call the will_change method!

This also goes for bang methods. So:

person = Person.first
person.name.downcase!
person.save

will not save anything! Save will never be called. To get the name saved you need to do

person = Person.first
person.name_will_change!
person.name.downcase!
person.save

This will save the name.