summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-11-17 12:35:04 +0100
committerhukl <contact@smyck.org>2009-11-17 12:35:04 +0100
commitbc6080a332806c2d0d359e05aaee2a7865d08673 (patch)
tree47e811f99c60a82d0dd6004b257d3a88a3d42652 /app
parentc4b8b7f61d0c455aa77f72b96de4ba02ed03aa41 (diff)
don't set the published_at upon creation of the first draft but rather on publish
Diffstat (limited to 'app')
-rw-r--r--app/models/node.rb2
-rw-r--r--app/models/page.rb10
2 files changed, 2 insertions, 10 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index e9d935a..4f67dcb 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -95,7 +95,9 @@ class Node < ActiveRecord::Base
95 def publish_draft! 95 def publish_draft!
96 if self.draft 96 if self.draft
97 self.head = self.draft 97 self.head = self.draft
98 self.head.published_at ||= Time.now
98 self.head.save! 99 self.head.save!
100
99 self.draft = nil 101 self.draft = nil
100 102
101 if staged_slug && (staged_slug != slug) 103 if staged_slug && (staged_slug != slug)
diff --git a/app/models/page.rb b/app/models/page.rb
index 22d2c69..00832bd 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -36,13 +36,9 @@ class Page < ActiveRecord::Base
36 36
37 # Filter 37 # Filter
38 before_create :set_page_title 38 before_create :set_page_title
39 before_create :set_published_at
40 before_create :set_template 39 before_create :set_template
41 before_save :rewrite_links_in_body 40 before_save :rewrite_links_in_body
42 41
43 # Validations
44 validates_presence_of :published_at, :on => :update
45
46 # Security 42 # Security
47 attr_accessible :title, :abstract, :body, :template_name, :published_at, :user_id 43 attr_accessible :title, :abstract, :body, :template_name, :published_at, :user_id
48 44
@@ -201,12 +197,6 @@ class Page < ActiveRecord::Base
201 end 197 end
202 end 198 end
203 199
204 def set_published_at
205 if self.published_at.nil?
206 self.published_at = Time.now
207 end
208 end
209
210 def set_template 200 def set_template
211 if node && node.update? 201 if node && node.update?
212 self.template_name = "update" 202 self.template_name = "update"