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