Created
March 10, 2015 16:28
-
-
Save elkelk/7bb04db3511894c0de75 to your computer and use it in GitHub Desktop.
Add reify_mongo to paper trail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in config/initializers/paper_trail.rb | |
# you need to manually create versions | |
# you'll need to set version.object = YAML::dump(self.attributes) in your Mongoid Model | |
class PaperTrail::Version < ActiveRecord::Base | |
def reify_mongo | |
klass = Object::const_get(item_type) | |
if defined? klass.mongo_session | |
coder = PaperTrail::Serializers::YAML unless coder.respond_to?(:dump) | |
attributes = coder.load(object) | |
klass.new(attributes) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment