Sha256: 2613aaffe3bcf488b139e03a2963ea4348a48b06a4451633fcbb55a250ccbfa7
Contents?: true
Size: 1.02 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
occams-1.0.1 | app/models/occams/cms/translation.rb |