Class: ShowcaseDigitalAsset

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

Overview

== Schema Information

Table name: showcase_digital_assets
Database name: primary

id :bigint not null, primary key
is_main :boolean default(FALSE), not null
position :integer
digital_asset_id :bigint not null
room_configuration_id :integer
showcase_id :bigint not null

Indexes

idx_sda_showcase_pos (showcase_id,position)
idx_sv2da_digital_asset_id (digital_asset_id)
idx_sv2da_room_configuration_id (room_configuration_id)
idx_unique_main_image_per_showcase_v2 (showcase_id) UNIQUE WHERE (is_main = true)

Foreign Keys

fk_rails_... (digital_asset_id => digital_assets.id)
fk_rails_... (showcase_id => showcases.id)

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Class Method Summary 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

#is_mainBoolean

Returns Whether this is the showcase's main image.

Returns:

  • (Boolean)

    Whether this is the showcase's main image.



92
# File 'app/models/showcase_digital_asset.rb', line 92

validates :is_main, inclusion: { in: [true, false] }

#positionInteger

Returns Display order within the showcase.

Returns:

  • (Integer)

    Display order within the showcase.



83
# File 'app/models/showcase_digital_asset.rb', line 83

validates :position, presence: true, numericality: { greater_than_or_equal_to: 0 }

Class Method Details

.mainActiveRecord::Relation<ShowcaseDigitalAsset>

A relation of ShowcaseDigitalAssets that are main. Active Record Scope

Returns:

See Also:



88
# File 'app/models/showcase_digital_asset.rb', line 88

scope :main, -> { where(is_main: true) }

Instance Method Details

#digital_assetDigitalAsset

Returns:



79
# File 'app/models/showcase_digital_asset.rb', line 79

belongs_to :digital_asset

#room_configurationRoomConfiguration

Optional link to a room configuration if the image was imported from a specific room

Returns:



86
# File 'app/models/showcase_digital_asset.rb', line 86

belongs_to :room_configuration, optional: true

#showcaseShowcase

Returns:



77
# File 'app/models/showcase_digital_asset.rb', line 77

belongs_to :showcase