Ben Johnson
2006-Nov-09 19:09 UTC
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Norris
2006-Nov-09 19:16 UTC
Re: Getting the raw database value? Not the attribute value.
Before you do product.save, load the old object into another variable old_product = Product_find(product.id) Ben Johnson wrote:> 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. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ben Johnson
2006-Nov-09 19:36 UTC
Re: Getting the raw database value? Not the attribute value.
Jason Norris 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/ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---