westonganger / active_snapshot

Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
MIT License
103 stars 16 forks source link

Conflict with awesome_nested_set #16

Closed billabel closed 2 years ago

billabel commented 2 years ago

I've installed the gem, added it to a single model, Skillset, with a has_and_belongs_to_many relationship with a model, Skill, that is also using awesome_nested_set.

I can create a snapshot and see everything stored in the db. However, when i try and run fetch_reified_items, I get this error.

ActiveRecord::ActiveRecordError (Unauthorized assignment to lft: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead.)

I found this issue: https://github.com/skyeagle/nested_set/issues/56 which seems to suggest that the problem is that the attribute needs to be accessed using self['rgt']

For my needs, all I'm trying to snapshot is a list skill_ids for the skillset. I don't actually need to restore the model. Just diving into your code and seeing what's possible. I found it today after installing and trying to work with paper_trail which didn't go very far...

westonganger commented 2 years ago

What you are describing here is a mechanism to exclude certain attributes from the snapshot. This is a duplicate of #12. See the proposed solution there.

At this time you can extract the code to your project and add the exclude logic there. I am not really ready to implement this functionality into this library yet, need more time to think about it.