Class: TranslationKeyResource

Inherits:
ApplicationRecord show all
Defined in:
app/models/translation_key_resource.rb

Overview

== Schema Information

Table name: translation_key_resources
Database name: primary

id :bigint not null, primary key
resource_attribute :string
resource_type :string not null
created_at :datetime not null
updated_at :datetime not null
resource_id :string not null
translation_key_id :integer not null

Indexes

idx_translation_key_resources_unique1 (translation_key_id,resource_type,resource_id) UNIQUE WHERE (resource_attribute IS NULL)
idx_translation_key_resources_unique2 (translation_key_id,resource_type,resource_id,resource_attribute) UNIQUE WHERE (resource_attribute IS NOT NULL)
index_translation_key_resources_on_translation_key_id (translation_key_id)

Foreign Keys

fk_rails_... (translation_key_id => translation_keys.id) ON DELETE => cascade

Constant Summary collapse

RESOURCE_TYPES =

Polymorphic owner allow-list — no DB FK on (resource_type, resource_id),
so pin the type to block injection / stale strings
(see doc/tasks/202607041714_POLYMORPHIC_FK_INTEGRITY_AUDIT.md).

%w[Item ProductSpecification].freeze

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#resource_typevoid (readonly)

This method returns an undefined value.



36
# File 'app/models/translation_key_resource.rb', line 36

validates :resource_type, inclusion: { in: RESOURCE_TYPES }, allow_nil: true

Instance Method Details

#resourceActiveRecord::Base

Returns:

  • (ActiveRecord::Base)


33
# File 'app/models/translation_key_resource.rb', line 33

belongs_to :resource, polymorphic: true

#translation_keyTranslationKey

Returns:



31
# File 'app/models/translation_key_resource.rb', line 31

belongs_to :translation_key