diff options
| author | hukl <contact@smyck.org> | 2009-11-02 22:18:49 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-11-02 22:18:49 +0100 |
| commit | 258ae60ca970629218447a5e1f5903fc80c8b6ee (patch) | |
| tree | 1cb61ecf1c7b0a01ab296ac561b17cbc5bed97e5 /app/models/page.rb | |
| parent | 6d77292c196b332f97b43b87d3377ba5b44e7dc2 (diff) | |
make sure user and published_at stay the same
Diffstat (limited to 'app/models/page.rb')
| -rw-r--r-- | app/models/page.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index 24c3ef2..56e1692 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -35,8 +35,12 @@ class Page < ActiveRecord::Base | |||
| 35 | 35 | ||
| 36 | # Filter | 36 | # Filter |
| 37 | before_create :set_page_title | 37 | before_create :set_page_title |
| 38 | before_create :set_published_at | ||
| 38 | before_save :rewrite_links_in_body | 39 | before_save :rewrite_links_in_body |
| 39 | 40 | ||
| 41 | # Validations | ||
| 42 | validates_presence_of :published_at, :on => :update | ||
| 43 | |||
| 40 | # Security | 44 | # Security |
| 41 | attr_accessible :title, :abstract, :body, :template_name, :published_at, :user_id | 45 | attr_accessible :title, :abstract, :body, :template_name, :published_at, :user_id |
| 42 | 46 | ||
| @@ -126,7 +130,6 @@ class Page < ActiveRecord::Base | |||
| 126 | self.tag_list = page.tag_list | 130 | self.tag_list = page.tag_list |
| 127 | self.template_name = page.template_name | 131 | self.template_name = page.template_name |
| 128 | self.published_at = page.published_at | 132 | self.published_at = page.published_at |
| 129 | self.user = page.user | ||
| 130 | 133 | ||
| 131 | # Getting rid of the auto-generated empty translations | 134 | # Getting rid of the auto-generated empty translations |
| 132 | self.globalize_translations.delete_all | 135 | self.globalize_translations.delete_all |
| @@ -196,6 +199,12 @@ class Page < ActiveRecord::Base | |||
| 196 | end | 199 | end |
| 197 | end | 200 | end |
| 198 | 201 | ||
| 202 | def set_published_at | ||
| 203 | if self.published_at.nil? | ||
| 204 | self.published_at = Time.now | ||
| 205 | end | ||
| 206 | end | ||
| 207 | |||
| 199 | def rewrite_links_in_body | 208 | def rewrite_links_in_body |
| 200 | begin | 209 | begin |
| 201 | if self.body | 210 | if self.body |
