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

Paper Trail compatibility #13

Merged
merged 11 commits into from
Jan 19, 2016

Conversation

dwbutler
Copy link
Contributor

Hi,

I've been trying to get serialized_attributes and Paper Trail to work happily together. It turns out that Paper Trail depends on quite a few ActiveRecord features that didn't happen to be implemented for serialized attributes.

Instead of creating a bunch of different pull requests, I decided to lump everything together and just summarize what got changed.

  • Fixed a bug where a reference to the 'data' field was hardcoded as data instead of using send(data_field).
  • Added support for dirty attributes by calling attribute_will_change!.
  • Overrode dup so it copies over a dup of the serialized data. Previously, the dup'ed object would keep a reference to the same serialized data as the original object. This fix is necessary because Paper Trail creates a version by duping the object, and then setting all attributes back to their previous values. So, modifying the dup was also modifying the serialized attributes on the original object.
  • Added support for []= AKA write_attribute to modify serialized data.

@dwbutler
Copy link
Contributor Author

I just realized I didn't add any specs for these changes. Let me know if these changes look good to you, and I'll go ahead and write some.

@technoweenie
Copy link
Owner

Are any of these ActiveRecord 3.x only? The changes look fine to me, but tests would be greatly appreciated :)

@dwbutler
Copy link
Contributor Author

I'm pretty sure these will all work in ActiveRecord 2. I'll definitely cook up some tests!

@dwbutler
Copy link
Contributor Author

Alright, I finished writing tests and verified that everything works in every ActiveRecord version and both Ruby 1.8.7 & 1.9.3. I would link to a Travis run, but I haven't been able to trigger a Travis run today, either automatically or manually.

@dwbutler
Copy link
Contributor Author

Looks like Travis is working again. Everything is green!

@courtenay
Copy link

+1, this also handily removes a deprecation warning when running this plugin on 3.2-stable -rails/rails@50d395f

technoweenie added a commit that referenced this pull request Jan 19, 2016
@technoweenie technoweenie merged commit 37f316d into technoweenie:master Jan 19, 2016
@technoweenie
Copy link
Owner

Sorry I'm terrible. We're not really using this gem anymore, so use at your own risk!

@dwbutler dwbutler deleted the paper_trail_compat branch January 20, 2016 00:28
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

Successfully merging this pull request may close these issues.

3 participants