I would like to add functionality like the update_on/created_on etc fields and intercept updates and creates so that I can drop in data into certain fields at the last minute. I am not sure what the best Railer approach would be. Observers? Override some AR methods from within my model? Any guidance on this would be appreciated, thanks. Chad
on 2007-03-04 15:43
on 2007-03-04 16:12
Hey Chad, you can use Rail's callbacks to handle this for you. Thus, if you need to do some post processing of create and update actions, then one can do the following within your model classes: def after_create # do some stuff end def after_update # do some stuff end For more information, please section 19.2 of AWDwRv2 Good luck, -Conrad
on 2007-03-04 16:29
Thanks Conrad, it was staring me in the face all this time.
on 2007-03-05 12:52
if you want to catch something before your models are saved, vs. after, which is what it sounds like, use before_save callback. it will be called before a create or update.