Sha256: 547a548ae210fb976a3970735e7edcc1ba0915ed13e192c1fc83ef5c9cd11680
Contents?: true
Size: 962 Bytes
Versions: 6
Compression:
Stored size: 962 Bytes
Contents
class Comfy::Cms::Translation < ActiveRecord::Base self.table_name = "comfy_cms_translations" include Comfy::Cms::WithFragments cms_has_revisions_for :fragments_attributes # -- 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
6 entries across 6 versions & 1 rubygems