How can you revert records in a way that respects REST conventions and routing?
I am looking for examples of how to setup my routes.rb and build the link & controller action to do the revert. All the examples I have found are pre-REST rails.
My understanding is that I need to have revert_to_version function in my resource controller.
I've never used acts-as-versioned in particular, but when I come across similar scenarios, the way I usually solve it is by reification of the attribute. In other words, I'd create a new resource only for the actual version number of the resource.
Eg.
would point to the actual version number of the resource with id :id. Then to change the actual version, we can just PUT desired number to it.
would revert our resource to the version 123.
As a convention, I'd use something like "last-but-one" as a value of :version to refer to the version that preceded the actual one.
Then, to rollback the actual version, we can just do:
--
Expanding my own answer:
In routes.rb we can do something like:
And in resources_controller.rb:
Hope that clarified my previous thoughts a bit. ;)