Skip to content

Instantly share code, notes, and snippets.

@elkelk
Created March 10, 2015 16:28
Show Gist options
  • Save elkelk/7bb04db3511894c0de75 to your computer and use it in GitHub Desktop.
Save elkelk/7bb04db3511894c0de75 to your computer and use it in GitHub Desktop.
Add reify_mongo to paper trail
# 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