Sha256: 9ba76c751c4de4b798aaa9f40b770e21ae79d13a9fe0c7277186f2784f312c5f
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true class Comfy::Cms::Translation < ActiveRecord::Base self.table_name = 'comfy_cms_translations' include Comfy::Cms::WithFragments cms_has_revisions_for :fragments_attributes delegate :site, to: :page # -- Relationships ----------------------------------------------------------- belongs_to :page # -- Callbacks --------------------------------------------------------------- before_validation :assign_layout # -- Scopes ------------------------------------------------------------------ scope :published, -> { where(is_published: true) } # -- Validations ------------------------------------------------------------- validates :label, presence: true validates :locale, presence: true, uniqueness: { scope: :page_id } validate :validate_locale private def validate_locale return unless page errors.add(:locale) if locale == page.site.locale end def assign_layout self.layout ||= page.layout if page.present? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_media_surfer-3.0.0 | app/models/comfy/cms/translation.rb |