diff options
| author | hukl <contact@smyck.org> | 2009-04-18 14:23:51 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-04-18 14:23:51 +0200 |
| commit | 6a13bb8c60b43f5798b7646791c982789d08215d (patch) | |
| tree | 0cfdd35a404a0666403d83ce4bbb5b99bf116683 /app/models/node.rb | |
| parent | 4b4846dc762df76ea82c3ef22787a7b193e357c6 (diff) | |
adding "restore_revision" functionality to the backend
Diffstat (limited to 'app/models/node.rb')
| -rw-r--r-- | app/models/node.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 | |||
| 81 | end | 81 | end |
| 82 | end | 82 | end |
| 83 | 83 | ||
| 84 | def restore_revision! revision | ||
| 85 | if page = self.pages.find_by_revision(revision) | ||
| 86 | self.head = page | ||
| 87 | self.save | ||
| 88 | else | ||
| 89 | nil | ||
| 90 | end | ||
| 91 | end | ||
| 92 | |||
| 84 | # returns an array with all parts of a unique_name rather than a string | 93 | # returns an array with all parts of a unique_name rather than a string |
| 85 | def unique_path | 94 | def unique_path |
| 86 | unique_name.split("/") rescue unique_name | 95 | unique_name.split("/") rescue unique_name |
