Class: ActiveBlog::BlogPost

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/active_blog/blog_post.rb

Instance Method Summary collapse

Instance Method Details

#build_cached_slugObject

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

#initObject



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_beObject



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_dashObject



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