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.
TIA,
Sean
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