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

versioning with carrierwave #134

Closed
eveevans opened this issue Feb 24, 2012 · 8 comments

Comments

Projects
None yet
4 participants
@eveevans
Copy link

commented Feb 24, 2012

When I try to version a Model that has a carrierwave object, PaperTrail try to stores the whole Ruby Object (CarrierWave Uploader) instead of a string that would be the carrierwave url

Example of version table, column object:


---
name: Foo
photo: !ruby/object:PhotoUploader
  model: !ruby/object:Photo
    attributes:
      id: 2
      name:
      .................
@airblade

This comment has been minimized.

Copy link
Collaborator

commented Feb 27, 2012

Does the :skip option help you (see #92)?

@eveevans

This comment has been minimized.

Copy link
Author

commented Feb 27, 2012

Well, skip is not exactly what I want because I need to store that attribute. This is a solution that a friend of mine did, using monkey-patch, http://stackoverflow.com/questions/9423279/papertrail-and-carrierwave/9440091#9440091

@airblade

This comment has been minimized.

Copy link
Collaborator

commented Mar 12, 2012

Sorry about the delay getting back to you. I hope it hasn't inconvenienced you.

I wasn't very clear when I mentioned :skip. I was wondering whether you could :skip every attribute other than your url attribute?

@airblade

This comment has been minimized.

Copy link
Collaborator

commented Mar 12, 2012

P.S. I see you're in Nicaragua. What a beautiful country!

@eveevans

This comment has been minimized.

Copy link
Author

commented Mar 12, 2012

Thanks,
I store all the attributes, including the url (instead of CarrierWave object), so my friend's solutions works fine, and I'm using it.

And, Yes, it's a beautiful country, let me know when you come

@airblade

This comment has been minimized.

Copy link
Collaborator

commented Mar 13, 2012

Ok, I see. I'm reluctant to put special cases in the code so I'll close this issue; anybody needing it in future can use your friend's solution.

@ilyakatz

This comment has been minimized.

Copy link

commented Feb 2, 2018

@airblade just ran into this as well. I agree that it's a special case for carrierwave but using :skip is also not great since it will remove auditing. do you have any other suggestions? or maybe at least a warning in the docs that this is possible? (carrier wave is a pretty popular gem, so i'm sure many people are affected). Also, FYI, this wasn't the case in previous paper_trail versions, so not sure what changed

@brettwgreen

This comment has been minimized.

Copy link

commented Mar 14, 2018

Mounting the uploader to a different model attribute than the database column that's being stored (using the mount_on attribute of CarrierWave) seems to avoid the problem without losing auditing of those fields. That was another answer on the mentioned StackOverflow question.

Alternatively, CarrierWave suggest you may be able to switch PaperTrail to JSON serialization (default is YAML):
https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-use-with-PaperTrail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.