Sha256: fe389b39c9b766d0d47fa0ff177ab3bbd3df2158c8b1cd8062f62077eb6fbd51

Contents?: true

Size: 977 Bytes

Versions: 6

Compression:

Stored size: 977 Bytes

Contents

module Wafflemix

  class Post < ActiveRecord::Base
    attr_accessible :draft, :link_url, :published_at, :translations_attributes, :locale, :title, :content, :tag_list, :category_ids, :meta_content_attributes

    acts_as_taggable
    ActsAsTaggableOn.force_parameterize = true

    default_scope :order => 'published_at DESC'
    scope :published, lambda { where("published_at <= ? AND draft != ?", Time.zone.now, true) }

    has_many :categoricals, :as => :categorical
    has_many :categories, :through => :categoricals
    has_many :images, :as => :imageable
    has_many :assets, :through => :images
    has_one :meta_content, :as => :metable, :class_name => 'Wafflemix::MetaContent'

    translates :title, :body, :excerpt

    accepts_nested_attributes_for :meta_content

    class Translation
      attr_accessible :title, :body, :excerpt, :locale
    end

    validates_presence_of :title

    def to_param
      "#{id}-#{link_url.gsub('/', '')}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wafflemix-0.0.6 app/models/wafflemix/post.rb
wafflemix-0.0.5 app/models/wafflemix/post.rb
wafflemix-0.0.4 app/models/wafflemix/post.rb
wafflemix-0.0.3 app/models/wafflemix/post.rb
wafflemix-0.0.2 app/models/wafflemix/post.rb
wafflemix-0.0.1 app/models/wafflemix/post.rb