ruby on rails - PaperTrail and batch versioning -


in rails app, have series of objects can reordered on page (each object saves position relative other objects on page). i'd versioning on how these objects arranged can implement undo/redo buttons.

i thought papertrail gem might option saving tree structure of how these objects sorted, issue when user rearranges objects, position of objects might change while others not, , papertrail seems save versions when object has been changed. i'd can save snapshot of state of objects in model. there way force papertrail save version call like

@objects.each |object|     @object = object.versions.scoped.last     @version = version.find(@object)     @version.reify.save! end 

for undoing changes? or there better way accomplish this?

for example (i'm sorting 2d arrays):

before making changes:

name   | position | ancestry step 0 |    0     |   0 step 1 |    1     |  371 step 2 |    2     |  371 

after making changes:

name   | position | ancestry step 0 |    0     |   0 step 1 |    1     |  371 step 2 |    2     |  371/374 

after trying undo:

name   | position | ancestry step 0 |    0     |   0 step 1 |    2     |  371 step 2 |    2     |  371 

notice how step 1, position should 1, since object didn't change before , after rearranging, reverted last saved version unique, incorrect.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -