helzer
1
Hi,
I want to add a column that would get calculated automatically
whenever I update an object.
For example, a checksum, of other columns in the model.
It should run whenever I do save, save!, update_attributes, etc.
Where would be a logical place to add this in my model?
Thanks,
Helzer
helzer
2
On Jun 10, 1:54 am, helzer [email protected] wrote:
Hi,
I want to add a column that would get calculated automatically
whenever I update an object.
For example, a checksum, of other columns in the model.
It should run whenever I do save, save!, update_attributes, etc.
Where would be a logical place to add this in my model?
before_save ?
Fred
helzer
3
class YourModel
def before_save
your callback code …
end
end
http://railsmanual.com/module/ActiveRecord::Callbacks
helzer
4
Thanks a lot Fred and alberto. I was just going to reinvent the wheel
here…
Helzer