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-4.14.9 spec/models/post.rb
bullet-4.14.8 spec/models/post.rb
bullet_instructure-4.14.8 spec/models/post.rb
bullet-4.14.7 spec/models/post.rb
bullet_instructure-4.14.7 spec/models/post.rb
bullet-4.14.6 spec/models/post.rb
bullet-4.14.5 spec/models/post.rb
bullet-4.14.4 spec/models/post.rb
bullet-4.14.3 spec/models/post.rb