From 6a13bb8c60b43f5798b7646791c982789d08215d Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 18 Apr 2009 14:23:51 +0200 Subject: adding "restore_revision" functionality to the backend --- app/models/node.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/models/node.rb') diff --git a/app/models/node.rb b/app/models/node.rb index b56dff5..0b92708 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -81,6 +81,15 @@ class Node < ActiveRecord::Base end end + def restore_revision! revision + if page = self.pages.find_by_revision(revision) + self.head = page + self.save + else + nil + end + end + # returns an array with all parts of a unique_name rather than a string def unique_path unique_name.split("/") rescue unique_name -- cgit v1.3