Sha256: 20f91ed4366b627cec01cc8e4c67c50a434b0bcf33e5d020fe59b59241e2809a

Contents?: true

Size: 414 Bytes

Versions: 29

Compression:

Stored size: 414 Bytes

Contents

class Post < ActiveRecord::Base
  belongs_to :category, inverse_of: :posts
  belongs_to :writer
  has_many :comments, inverse_of: :post

  validates :category, presence: true

  scope :preload_comments, -> { includes(:comments) }
  scope :in_category_name, ->(name) { where(['categories.name = ?', name]).includes(:category) }
  scope :draft, -> { where(active: false) }

  def link=(*)
    comments.new
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
bullet-5.7.4 spec/models/post.rb
bullet-5.7.3 spec/models/post.rb
bullet-5.7.2 spec/models/post.rb
bullet-5.7.1 spec/models/post.rb
bullet-5.7.0 spec/models/post.rb
bullet-5.6.1 spec/models/post.rb
bullet-5.6.0 spec/models/post.rb
bullet-5.5.1 spec/models/post.rb
bullet-5.5.0 spec/models/post.rb
bullet-5.4.3 spec/models/post.rb
bullet-5.4.2 spec/models/post.rb
bullet-5.4.1 spec/models/post.rb
bullet-5.4.0 spec/models/post.rb
bullet-5.3.0 spec/models/post.rb
bullet-5.2.1 spec/models/post.rb
bullet-5.2.0 spec/models/post.rb
bullet-5.1.1 spec/models/post.rb
bullet-5.1.0 spec/models/post.rb
bullet-5.0.0 spec/models/post.rb
bullet-4.14.10 spec/models/post.rb