Getting the raw database value? Not the attribute value

Lets say you have an object of the Product class. So you do:

product.price = 22.50

Then in your before_save method for the Product model you want to get
the value that is in the database, no the value just set. How do you get
the value in the database?

Thanks for your help.

Before you do product.save, load the old object into another variable

old_product = Product_find(product.id)

Jason N. wrote:

Before you do product.save, load the old object into another variable

old_product = Product_find(product.id)

I actually found a pretty cool plugin for this:

http://svn.viney.net.nz/things/rails/plugins/acts_as_modified/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs