Sha256: 3705ce2f84fabe24bd1403bbaf61ebec4a68bfc30aa3ef12b8245a73505eab04

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

class Article < Content
  has_permalink :title
  acts_as_taggable_on :tags

  validates_presence_of :title
  validates_presence_of :body

  def excerpt
    content = body[0, 300]
    words = content.gsub(/<\/?[^>]+>/, "").split(' ')
    words[0 .. 59].join(' ') + '...'
  end

  def url
    "/articles/%04d/%02d/%02d/#{permalink}" % [created_at.year, created_at.month, created_at.day]
  end
  
  def next
    site.articles.published.order('id').where("id > ?", id).first
  end
  
  def prev
    site.articles.published.order('id').where("id < ?", id).first
  end
  
  def to_param
    "#{id}-#{permalink}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content_engine-0.1.0 app/models/article.rb