Sha256: 7a0e9c89b529075bdd8c35ddbd3135c4354f39e61225dc98f2c4b5d19c0bb868
Contents?: true
Size: 1022 Bytes
Versions: 17
Compression:
Stored size: 1022 Bytes
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
17 entries across 17 versions & 6 rubygems