From bc6080a332806c2d0d359e05aaee2a7865d08673 Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 17 Nov 2009 12:35:04 +0100 Subject: don't set the published_at upon creation of the first draft but rather on publish --- app/models/node.rb | 2 ++ app/models/page.rb | 10 ---------- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'app') 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 def publish_draft! if self.draft self.head = self.draft + self.head.published_at ||= Time.now self.head.save! + self.draft = nil 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 # Filter before_create :set_page_title - before_create :set_published_at before_create :set_template before_save :rewrite_links_in_body - # Validations - validates_presence_of :published_at, :on => :update - # Security attr_accessible :title, :abstract, :body, :template_name, :published_at, :user_id @@ -201,12 +197,6 @@ class Page < ActiveRecord::Base end end - def set_published_at - if self.published_at.nil? - self.published_at = Time.now - end - end - def set_template if node && node.update? self.template_name = "update" -- cgit v1.3