Sha256: 070d6dfb80c33c84b546c2c545d270e6d8410794f206cca49731b784d4fcab92
Contents?: true
Size: 1.24 KB
Versions: 16
Compression:
Stored size: 1.24 KB
Contents
class Article < ActiveRecord::Base belongs_to :category acts_as_content_node acts_as_commentable has_assets acts_as_textiled :body acts_as_taggable_on :tags named_scope :categorised, lambda { |category| return {} if category.nil? category = Category.find(category) unless category.nil? or category.is_a? Category { :conditions => { :category_id => category.id } } } named_scope :in_time_delta, lambda { |year, month, day| return {} if year.blank? from = Time.mktime(year, month || 1, day || 1) to = from + 1.year to = from + 1.month unless month.blank? to = from + 1.day unless day.blank? to = to.tomorrow unless month.blank? { :conditions => ['published_at BETWEEN ? AND ?', from, to ] } } validates_presence_of :body, :description, :tag_list, :if => :publish # Finds one article which was posted on a certain date and matches the supplied dashed-title def self.find_by_permalink(year, month, day, permalink) if result = in_time_delta(year, month, day).first( :conditions => ["permalink = ?", permalink] ) result else raise ActiveRecord::RecordNotFound, "Couldn't find article with permalink #{permalink} on #{year}.#{month}.#{day}}" end end end
Version data entries
16 entries across 16 versions & 1 rubygems