Question

I'm interested in using the vestal_versions gem in my rails app, but I'm wondering if anyone knows if there's any way that I can create a new version, but not actually update the associated ActiveRecord.

For instance, if I have a user with first name "jim", and I create a new version with first name "steve", I would want to be able to persist the version without changing the parent record until I want to at a later time (using revert_to!(newer_version) or some such).

If this isn't built into the gem, any clues on where I should start patching?

Was it helpful?

Solution

After investigating the behavior of this gem, I found that this is not something that vestal_versions is really set up to do.

You can force this behavior with something like:

def create_version
  merge_version_changes
  create_version
end

in a 'versioned' model, but while that creates a new version with the changes that you've put into your live ActiveRecord without modifying the parent object's table, when you use:

blah = Blah.first
blah.version

it will tell you that you are using the latest version, but not load up that data (since it never changed). If you use:

blah.revert_to(:last)

It will not change your record since it thinks that you are already using the latest version. Etc..

To make a long story short, vestal_versions is not intended have this type of behavior, and it should not be expected to do it. I'm investigating the has_drafts gem right now as it seems to be closer to what I'm looking to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top