summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <hukl@eight.local>2009-02-07 23:36:57 +0100
committerhukl <hukl@eight.local>2009-02-07 23:36:57 +0100
commit3289d0a7a0589baa5bff470df4e07ec2bed99222 (patch)
treee7e18ae7994f9b428139b5c3e7200bae442e2700
parent15612d2ea6e62cd3417273f90dd738d13522b014 (diff)
added draft method to node model
-rw-r--r--app/models/node.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index e08e228..4e865e3 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -33,6 +33,22 @@ class Node < ActiveRecord::Base
33 33
34 # Instance Methods 34 # Instance Methods
35 35
36 def draft
37
38 # check if there is a page which has a nil :published_at column
39 # if there is one - it is considered a draft else a new revision is
40 # created
41
42 if draft = pages.find_by_published_at(nil)
43 draft
44 else
45 # make a new fresh page with node reference
46 draft = Page.new( :node_id => id)
47 end
48
49 draft
50 end
51
36 # returns an array with all parts of a unique_name rather than a string 52 # returns an array with all parts of a unique_name rather than a string
37 def unique_path 53 def unique_path
38 unique_name.split("/") rescue unique_name 54 unique_name.split("/") rescue unique_name