Class: EmbeddedFaqAsset
- Inherits:
-
EmbeddedAsset
- Object
- ActiveRecord::Base
- ApplicationRecord
- EmbeddedAsset
- EmbeddedFaqAsset
- Defined in:
- app/models/embedded_faq_asset.rb
Overview
== Schema Information
Table name: embedded_assets
Database name: primary
id :bigint not null, primary key
asset_type :string
options :jsonb not null
parent_type :string not null
type :string
uuid :uuid not null
created_at :datetime not null
updated_at :datetime not null
asset_id :bigint
parent_id :bigint not null
Indexes
idx_embedded_assets_on_asset_and_type (asset_id,asset_type,type)
idx_embedded_assets_parent_asset (parent_type,parent_id,asset_type,asset_id)
index_embedded_assets_on_asset (asset_type,asset_id)
index_embedded_assets_on_type (type)
index_embedded_assets_on_uuid (uuid)
Constant Summary collapse
- PERMITTED_OPTIONS =
FAQ-specific permitted options for controller
%i[ title sort position display_style show_question show_answer include_schema heading_level ].freeze
Instance Attribute Summary
Attributes inherited from EmbeddedAsset
Class Method Summary collapse
-
.faq_ids_for_widget(uuid) ⇒ Object
Get all FAQ IDs for a widget (all records with same UUID), ordered by position.
Instance Method Summary collapse
-
#render_options ⇒ Object
Returns render options formatted for FaqProvider/oEmbed.
Methods inherited from EmbeddedAsset
#asset, faqs, for_asset_type, for_parent, images, #parent, products, #to_param, videos
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.faq_ids_for_widget(uuid) ⇒ Object
Get all FAQ IDs for a widget (all records with same UUID), ordered by position
67 68 69 70 71 |
# File 'app/models/embedded_faq_asset.rb', line 67 def self.(uuid) where(uuid: uuid) .order(Arel.sql("(options->>'p')::int NULLS LAST, id")) .pluck(:asset_id) end |
Instance Method Details
#render_options ⇒ Object
Returns render options formatted for FaqProvider/oEmbed
54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/embedded_faq_asset.rb', line 54 def { title: title, sort: sort, display_style: display_style, show_question: show_question, show_answer: show_answer, include_schema: include_schema, heading_level: heading_level }.compact end |