Class: ActiveBlog::BlogPost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveBlog::BlogPost
- Defined in:
- app/models/active_blog/blog_post.rb
Instance Method Summary collapse
-
#build_cached_slug ⇒ Object
protected methods.
- #init ⇒ Object
- #title_must_not_be ⇒ Object
- #title_must_not_start_with_dash ⇒ Object
Instance Method Details
#build_cached_slug ⇒ Object
protected methods
21 22 23 24 25 26 |
# File 'app/models/active_blog/blog_post.rb', line 21 def build_cached_slug # Don't build slug if it already exists. if self.cached_slug.nil? self.cached_slug = title.to_slug end end |
#init ⇒ Object
38 39 40 41 |
# File 'app/models/active_blog/blog_post.rb', line 38 def init # Set now as the default published_at date. Only set if currently nil self.published_at ||= Time.zone.now end |
#title_must_not_be ⇒ Object
34 35 36 |
# File 'app/models/active_blog/blog_post.rb', line 34 def title_must_not_be errors.add(:title, "cannot be named 'archives'") if title == 'archives' end |
#title_must_not_start_with_dash ⇒ Object
28 29 30 31 32 |
# File 'app/models/active_blog/blog_post.rb', line 28 def title_must_not_start_with_dash if title.starts_with?('-') errors.add(:title, 'cannot start with a dash') end end |