Ruby on Rails Wednesday, August 20, 2014

On Wednesday, August 20, 2014 11:37:03 PM UTC-4, Phil wrote:
 
Before blaming 'incorrect code' or bad programmers, look back again at my example.  It's quite trivial and reproducible.  Saves order line items, in what I would consider a completely sane and logical way, call back line items to compute tax, add the last line item (the tax), and then throws the @order to payment processing, mailers, receipt page... where totals are wrong and tax is missing.  I understand that doing things differently avoid the problem and I have used them to fix this issue on my end, but I still am quite skeptical as to how a programmer is supposed to know about these pitfalls.

It sounds like you are thinking in terms of the database, while ActiveRecord is an ORM.  You need to think of it in terms of objects which happen to be persisted in a database.   When you create a line item record in the database, your @order object does not know about it, so you have to tell it to reload.  The only other ORM I've used is Apple's CoreData, and the same thing applies.  If you modify the database without using the object in question, the object will not be updated until you reload it.  

Jim

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/68eb7964-63af-4f7d-80a7-875c166e4139%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment