-
Notifications
You must be signed in to change notification settings - Fork 895
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
Paper_trail creates a first version with the custom meta attribute approved
set to false even when it should be true
#385
Comments
By the way, I'm riding rails 3.2.14 and paper_trail 2.7.2. |
I found a temporary fix:
|
Please see #185. The metadata columns get filled with the attribute as it is |
Ok thank you!
|
Yes, but just realize that the value being stored in that column (if it changes frequently) may not actually represent the value for the state of the object represented in that corresponding version. For instance: content = Content.create!(:approved => true)
content.update_attribute(:approved, false)
content.versions.last.approved # => false
content.versions.last.reify # => #<Content id: 1, approved: true> As stated in the README:
The reason why PaperTrail doesn't record about the state of the current object is because it is redundant, since you can access that data simply by accessing the live object's record. |
Uhm, I'm not following you here, because in the README you also state:
This is the use I intended for the So I guess I'll have to stick with the above mentioned temporary fix. |
That's what I'm trying to say, the metadata columns, by default, if pointed at an attribute, will be populated by the value of that attribute at the state it was at before the modification was made. I guess you could fix this by either removing the default value for the column, or having the default value be |
I can't set the approved default to true because unapproved content may be created, anyway I got you and I think I found an acceptable solution, thank you! |
I got confused too. At first I thought it was a bug that made the meta value always 1 step behind the current state. But now I understand thats truly how it works. Thanks. |
The Content model has a bunch of attributes, but one of them is
approved
defined by this code in its migration:And in its ContentVersion migration:
Of course, Content also has paper_trail:
This code creates and saves a content object:
I expect it's first version to have
approved = true
, but, checking it via rails console it's easy to find out thatcontent.versions.first.approved
isfalse
, while it should betrue
:Why is that?
The text was updated successfully, but these errors were encountered: