views:

23

answers:

1

Suppose I do

>> a = Annotation.first
>> a.body
=> "?"
>> a.body = "hello"
=> "hello"

Now, I haven't saved a yet, so in the database its body is still ?. How can I find out what a's body was before I changed it?

I guess I could do Annotation.find(a.id).body, but I wonder if there's a cleaner way (e.g., one that doesn't do a DB query)

+2  A: 

a.body_was

You can also check to see if it's dirty with a.changed? and/or a.body_changed?

jdl