Skip to content
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

reify does not work with custom setters #525

Closed
graaff opened this issue Apr 20, 2015 · 3 comments
Closed

reify does not work with custom setters #525

graaff opened this issue Apr 20, 2015 · 3 comments
Milestone

Comments

@graaff
Copy link

graaff commented Apr 20, 2015

I'm working with paper_trail 3.0.7 and objects with custom setters don't properly reify. I'm running into this issue specifically with the acts-as-taggable-on gem. This gem introduces a tag_list getter and setter as an interface to handle multiple tags via a string.
The object I'm trying to reify has a tag_list attribute in it, but this fails with the following error:

    from /usr/lib64/ruby/gems/2.0.0/gems/activerecord-4.0.13/lib/active_record/attribute_methods/dirty.rb:70:in `write_attribute'
    from /usr/lib64/ruby/gems/2.0.0/gems/activerecord-4.0.13/lib/active_record/attribute_methods.rb:359:in `[]='
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:152:in `block (2 levels) in reify'
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:150:in `each'
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:150:in `block in reify'
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:225:in `call'
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:225:in `without_identity_map'
    from /usr/lib64/ruby/gems/2.0.0/gems/paper_trail-3.0.7/lib/paper_trail/version_concern.rb:117:in `reify'

This happens because the specific code in version_concern.rb checks if the object reponds to "tag_list=" (which is does), but then proceeds to use "object[:tag_list] =" instead, which is not the same thing. I would at least expect the check and method to match so it would produce consistent results. I would also expect the setter to be called so that acts-as-taggable-on can do its magic on the tag_list value.

@batter
Copy link
Collaborator

batter commented Apr 27, 2015

I believe PR #512 would fix this... I just need to do a bit more research to see what (if any) ramifications there are by changing it / figure out why it was using the object[:tag_list] = syntax in the first place..

@batter
Copy link
Collaborator

batter commented Apr 27, 2015

Can you try this vattr_support branch and see if it fixes your issue? Thanks

@graaff
Copy link
Author

graaff commented Apr 29, 2015

Yes, this works as expected for my case, including the reification of the tags via tag_list.

@batter batter closed this as completed in a8b5d7d Apr 29, 2015
batter added a commit that referenced this issue Apr 29, 2015
…with custom setters in VersionConcern#reify)
@batter batter added this to the 4.0.0 milestone Apr 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants