Class: ProductTours::Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ProductTours::Post
- Defined in:
- app/models/product_tours/post.rb
Constant Summary collapse
- KEY_FORMAT =
/\A[a-z0-9]+(?:[._-][a-z0-9]+)*\z/- STATUSES =
%w[draft published].freeze
- DASHBOARD_STATUSES =
%w[published draft].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.description_supported? ⇒ Boolean
32 33 34 35 36 37 |
# File 'app/models/product_tours/post.rb', line 32 def self.description_supported? reflect_on_association(:rich_text_description).present? && ActionText::RichText.table_exists? rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid, NameError false end |
.video_upload_supported? ⇒ Boolean
39 40 41 42 43 44 |
# File 'app/models/product_tours/post.rb', line 39 def self.video_upload_supported? reflect_on_association(:video_attachment).present? && ActiveStorage::Blob.table_exists? && ActiveStorage::Attachment.table_exists? rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid, NameError false end |
Instance Method Details
#action_post ⇒ Object
64 65 66 67 68 |
# File 'app/models/product_tours/post.rb', line 64 def action_post return if action_post_key.blank? self.class.find_by(locale: locale, key: action_post_key) end |
#resolved_video ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/product_tours/post.rb', line 50 def resolved_video return { kind: 'upload', provider: 'upload', url: nil } if uploaded_video? resolved = VideoResolver.resolve(video_url) return if resolved.nil? { kind: resolved.kind, provider: resolved.provider, url: resolved.url, thumbnail_url: .to_h['thumbnail_url'] }.compact end |
#uploaded_video? ⇒ Boolean
46 47 48 |
# File 'app/models/product_tours/post.rb', line 46 def uploaded_video? self.class.video_upload_supported? && video.attached? end |