Class: DynamicBlock
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- DynamicBlock
- Includes:
- Checkable, RequiredUniqueSlug, Toggleable
- Defined in:
- app/models/dynamic_block.rb
Overview
Dynamic block
Attributes:
body [Text], optional
created_at [DateTime]
data [JSON]
slug [String]
updated_at [DateTime]
visible [Boolean]
Constant Summary collapse
- SLUG_LIMIT =
100
Class Method Summary collapse
-
.[](slug) ⇒ String
Get body of visible block with given slug or empty string.
- .entity_parameters ⇒ Object
Instance Method Summary collapse
Class Method Details
.[](slug) ⇒ String
Get body of visible block with given slug or empty string
Can be used in views for quick output
32 33 34 |
# File 'app/models/dynamic_block.rb', line 32 def self.[](slug) visible.find_by(slug: slug)&.body.to_s end |
.entity_parameters ⇒ Object
36 37 38 |
# File 'app/models/dynamic_block.rb', line 36 def self.entity_parameters %i[body slug visible] end |
Instance Method Details
#text_for_link ⇒ Object
40 41 42 |
# File 'app/models/dynamic_block.rb', line 40 def text_for_link slug end |