Sha256: 8e15ce2453d1706f78ae4c8e296d86a9db10d51cc1c49de659fe94730ed38683

Contents?: true

Size: 995 Bytes

Versions: 24

Compression:

Stored size: 995 Bytes

Contents

class CamaleonCms::CustomFieldsRelationship < ActiveRecord::Base
  self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}custom_fields_relationships"

  # attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class,
  # :custom_field_slug, :group_number
  default_scope { order("#{CamaleonCms::CustomFieldsRelationship.table_name}.term_order ASC") }

  # relations
  belongs_to :custom_fields, class_name: 'CamaleonCms::CustomField', foreign_key: :custom_field_id

  # validates :objectid, :custom_field_id, presence: true
  validates :custom_field_id, presence: true # error on clone model

  after_save :set_parent_slug
  after_save :update_model_owner # TODO: convert this model into polymorphic

  private

  def set_parent_slug
    # self.update_column('custom_field_slug', self.custom_fields.slug)
  end
  
  # touch owner model
  def update_model_owner
    "CamaleonCms::#{object_class}".constantize.find(objectid).touch rescue nil # owner model
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
camaleon_cms-2.5.3.1 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.5.3 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.5.2 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms_rails6-2.5.0 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.5.1 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.5.0 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.9 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.8 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.7 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.6 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.5 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.4 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.3 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.2 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.1 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.6.0 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.5.14 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.5.13 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.5.12 app/models/camaleon_cms/custom_fields_relationship.rb
camaleon_cms-2.4.5.11 app/models/camaleon_cms/custom_fields_relationship.rb