-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to the Rails updated_at column don't appear in version changesets #323
Comments
What database adapter are you using? PaperTrail retrieves the objects to insert into the before_update do
puts "--- changes:"
p changes
end And see what gets printed out into the console when you go to update the record? If the |
I'm using Postgres on Heroku via version 0.17.0 of the pg gem. And yes, the updated_at column is definitely not in changes. My guess would be that Rails updates updated_at via a before_update callback, and consequently order cannot be guaranteed. However, I notice that the updated_at attribute is available when consulting changes in the after_update ... so, maybe PaperTrail should use the changes object from an after_update callback? That is, I added this to my user class: before_update { dputs changes } ... and get this as the printout:
|
Sounds like the issue is with Rails. In order for that attribute to get pulled into the changes, it must be available in the |
True. It just seems a bit brittle to me to use #changes in .before_update rather OTOH, I personally would use .before_validation on: :update to update model Also, I can infer the updated_at value from Version#created_at, so we're Thanks for your help! On Mon, Jan 27, 2014 at 7:45 AM, Ben Atkins notifications@git.luolix.topwrote:
|
If I update some Rails model attribute then Rails will perform the update I requested and also update the updated_at field for that model.
However, the PaperTrail version changeset for the change doesn't contain a hash key
updated_at: [<pre_value>, <post_value>]
.PaperTrail does correctly record both :created_at and :updated_at when a record is initially created. The bug only appears with subsequent attribute updates.
I'm using Rails 3.2.16 with Ruby 1.9.3p429.
And yes, I do know I can reconstruct the approximate updated_at from the created_at field on the Version. Still, it would be nice if the changeset record recorded the change.
The text was updated successfully, but these errors were encountered: