summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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