Files
nairobi/app/models/milestone.rb
Senén Rodero Rodríguez 2e8e7b83a5 Remove monkey patch
Since globalize version update this is no longer needed. New Globalize
version initializes globalized_model correctly when building new
translations.
2019-06-27 09:19:35 +02:00

25 lines
738 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) }
scope :with_status, -> { where("status_id IS NOT NULL") }
def self.title_max_length
80
end
end