Files
nairobi/app/models/milestone.rb
Javi Martín 8ae138aa19 Add and apply Rails/WhereNot rubocop rule
We simplify the code a little bit, and make it more consistent since we
were already using `where.not` in most places.
2021-08-09 23:52:47 +02:00

24 lines
743 B
Ruby

class Milestone < ApplicationRecord
include Imageable
include Documentable
translates :title, :description, touch: true
include Globalizable
translation_class_delegate :status_id
belongs_to :milestoneable, polymorphic: true
belongs_to :status
validates :milestoneable, presence: true
validates :publication_date, presence: true
validates_translation :description, presence: true, unless: -> { status_id.present? }
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
scope :published, -> { where("publication_date <= ?", Date.current.end_of_day) }
scope :with_status, -> { where.not(status_id: nil) }
def self.title_max_length
80
end
end