diff options
| author | hukl <contact@smyck.org> | 2009-10-07 17:53:29 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-10-07 17:53:29 +0200 |
| commit | 5e1f877d6fb4f7504039444ad36ad7b964fc934e (patch) | |
| tree | a94f52cdbf3a3419e030ae0bf32160a06e3a5c0b | |
| parent | 16e0ce1316bb24f5d7973990fa438b8b3f2754e5 (diff) | |
and add it back in
| -rw-r--r-- | lib/update.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/update.rb b/lib/update.rb new file mode 100644 index 0000000..480bb0b --- /dev/null +++ b/lib/update.rb | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | module Update | ||
| 2 | |||
| 3 | def self.find_or_create_parent | ||
| 4 | current_year = Time.now.year.to_s | ||
| 5 | |||
| 6 | if parent = Node.find_by_unique_name("updates/#{current_year}") | ||
| 7 | parent | ||
| 8 | else | ||
| 9 | unless updates = Node.find_by_unique_name("updates") | ||
| 10 | updates = Node.root.children.create(:slug => "updates") | ||
| 11 | end | ||
| 12 | parent = updates.children.create(:slug => current_year) | ||
| 13 | parent | ||
| 14 | end | ||
| 15 | end | ||
| 16 | |||
| 17 | end \ No newline at end of file | ||
