# Getting the raw database value? Not the attribute value

**URL:** <https://www.ruby-forum.com/t/getting-the-raw-database-value-not-the-attribute-value/75424>\
**Category:** Rails\
**Created:** [November 9, 2006, 8:09pm UTC](https://www.ruby-forum.com/t/getting-the-raw-database-value-not-the-attribute-value/75424 "2006-11-09T20:09:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [November 9, 2006, 8:09pm UTC](https://www.ruby-forum.com/t/getting-the-raw-database-value-not-the-attribute-value/75424/1 "2006-11-09T20:09:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [November 9, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/getting-the-raw-database-value-not-the-attribute-value/75424/2 "2006-11-09T20:18:05Z")

</div>

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

old\_product = Product\_find(product.id)

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [November 9, 2006, 8:36pm UTC](https://www.ruby-forum.com/t/getting-the-raw-database-value-not-the-attribute-value/75424/3 "2006-11-09T20:36:39Z")

</div>

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/](http://svn.viney.net.nz/things/rails/plugins/acts_as_modified/)
