On Aug 16, 10:17 pm, Matt Jones <[email protected]> wrote:
> On Aug 16, 2010, at 11:43 PM, Abbasi Ujjainwala wrote:

> class Time < ActiveRecord::Base
> ...
>    after_save :adjust_time_to_burn
>
>    def adjust_time_to_burn
>      self.story.update_attribute(:total_time_to_burn,  
> story.total_time_to_burn - time_burned)
>    end

Just a note on this code, you'd probably want your time model to be
create only otherwise if a model gets updated, the time will get
subtracted from the total a second (3rd, etc.) time.  I'd also
probably change it to after_create just because I'd be paranoid of
some process modifying it and causing a very hard to track down bug.

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to