Class: DynamicPage
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- DynamicPage
- Includes:
- Checkable, HasLanguage, HasSimpleImage, HasUuid, MetaTexts, Toggleable
- Defined in:
- app/models/dynamic_page.rb
Overview
Dynamic page
Attributes:
body [text]
created_at [DateTime]
data [jsonb]
language_id [Language], optional
name [string]
simple_image_id [SimpleImage], optional
slug [string]
updated_at [DateTime]
url [string], optional
uuid [uuid]
visible [boolean]
Constant Summary collapse
- NAME_LIMIT =
100
- SLUG_LIMIT =
100
- URL_LIMIT =
100
Class Method Summary collapse
Instance Method Summary collapse
- #long_slug ⇒ Object
- #meta_heading ⇒ Object
- #meta_title ⇒ Object
- #text_for_link ⇒ Object
- #world_url ⇒ Object
Methods included from HasSimpleImage
Class Method Details
.[](slug) ⇒ Object
44 45 46 |
# File 'app/models/dynamic_page.rb', line 44 def self.[](slug) find_by(slug: slug) end |
.entity_parameters ⇒ Object
48 49 50 |
# File 'app/models/dynamic_page.rb', line 48 def self.entity_parameters %i[body language_id name simple_image_id slug url visible] end |
Instance Method Details
#long_slug ⇒ Object
52 53 54 |
# File 'app/models/dynamic_page.rb', line 52 def long_slug language.nil? ? slug : "#{slug} (#{language.code})" end |
#meta_heading ⇒ Object
69 70 71 72 |
# File 'app/models/dynamic_page.rb', line 69 def heading = data.dig('meta', 'heading') heading.blank? ? name : heading end |
#meta_title ⇒ Object
64 65 66 67 |
# File 'app/models/dynamic_page.rb', line 64 def title = data.dig('meta', 'title') title.blank? ? name : title end |
#text_for_link ⇒ Object
56 57 58 |
# File 'app/models/dynamic_page.rb', line 56 def text_for_link long_slug end |
#world_url ⇒ Object
60 61 62 |
# File 'app/models/dynamic_page.rb', line 60 def world_url url.blank? ? '/' : url end |