On 6 Sep 2008, at 19:54, schof wrote:
>
> I need a suggestion for a calculated value. I have an order object
> with a total in it. I''d like to recalculate the order total
during
> the checkout process (as user selects shipping, etc.) but after the
> checkout is complete, I''d like to store it in the database for
> performance and searching reasons.
>
> Does that make sense? Any suggestions on how to pull this off? I was
> thinking an alias to the database method and checking the status of a
> checkout_complete boolean.
>
You could do something like
def total
self[:total] || calculate_total
end
Which does what it says: if there is a non nil total attribute then it
will use that, if not it calculates it.
Fred
> TIA,
> Sean
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---