Sha256: 7e16e4a4a1c4818b8b4461cef1f266130e0a3f9c190eda0b17cbd048212addee
Contents?: true
Size: 1.02 KB
Versions: 12
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true class Occams::Cms::Translation < ActiveRecord::Base self.table_name = 'occams_cms_translations' include Occams::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
12 entries across 12 versions & 1 rubygems