-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Hey guys,
I'm using mongoid 2.5.0 on a Rails app, and I have some documents with versioning enabled, but I'm wondering what the best approach is to revert to an older version of a document? It doesn't seem like there are any methods that allow for this. Say I have a setup like this:
> doc = Document.first
=> #<Document _id: "4f46c8439926004087000003", _type: nil, title: "Second version">
> doc.first.versions.size
=> 2
> doc.version
=> 2
> doc.versions.first
=> #<Document _id: , _type: nil, title: "First version">
Would my best bet be to do something like this?:
> doc.update_attributes(doc.versions.first.attributes)
Also, is there an easy way to discard versions? Ideally I'd like to actually essentially "rollback" a document (revert to an older version, discard the ones that occur afterwards), but this seems like it's not as easy as I was envisioning. Am I missing something here?
Cheers,
Ben