Node Versioning

(Ryan Heneise) #1

Has anyone done any work with node versioning, using PaperTrail or similar? I’m wondering how that would work with the jsonb field_store.

I’m thinking, once users start touching content, that it would be nice to have a way to roll back mistakes to an earlier version of the page.

(Aaron Russell) #2

Versioning IS something I want to see in PushType eventually, but as of yet it’s not something I’ve taken any further than a nice idea for the future.

I’ve not used the paper_trail gem, but have just had a quick look. Seems to save a serialised version of the object/version in the database from what I can make out? I can’t think of any reason why that wouldn’t work with the jsonb data on node objects.

When I’ve thought about this in the past I’ve wondered if the node object could simply just have a relationship to itself:

class PushType::Node < ActiveRecord::Base
  has_many :versions, class_name: 'push_type/node', dependent: :destroy
  belongs_to :current_version, inverse_of: :versions

  after_save :create_new_version

There’s obviously a bit more to it that that, but I think you get the gist :stuck_out_tongue: Really im not sure whether a DIY approach would be any better or worse than depending on a ready built solution like paper_trail. Needs some experimentation.

Right now my priorities are working on the new admin UI, but this is something I’d be keen to see. Contributions and experiments on this idea very much welcome :smiley:

(Chris Giddings) #3

Upvote on this for sure.

Even just to be able to have a published version and an unpublished draft simultaneously would be great.