Sha256: 3dbfe2e34f6954e42f220e5992d73655df91729065933902ab8a436745c25ef0
Contents?: true
Size: 471 Bytes
Versions: 10
Compression:
Stored size: 471 Bytes
Contents
# frozen_string_literal: true class Post < ApplicationRecord validates :title, presence: true, uniqueness: true validates :body, presence: true validates :category_id, presence: true belongs_to :category, inverse_of: :posts scope :published, -> { where "published_at <= date('now')" } scope :unpublished, -> { where "published_at IS NULL OR published_at > date('now')" } def published? published_at.present? && published_at < Time.current end end
Version data entries
10 entries across 10 versions & 1 rubygems