views:

43

answers:

2

In order to clean up some bad data I added a before save callback. Now I need to force all the models to be saved again. However no update operation happens if I do this

User.first.save

How do I force all the models to perform save operation even though I don't have any attributes changed.

+4  A: 

You should be able to use touch, it fires callbacks when it saves.

Alternatively turn off partial_updates: ActiveRecord::Base.partial_updates = false

cwninja
A: 

If the attributes aren't modified it won't save. If you modified something during the cleanup, it should be able to be saved.

cgr
cleanup happens during the callback. And the callbacks are not fired until I change the attributes which I am not doing.
Roger