Class: EditableBlock
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- EditableBlock
- Includes:
- Checkable, Toggleable
- Defined in:
- app/models/editable_block.rb
Constant Summary collapse
- DESCRIPTION_LIMIT =
250
- NAME_LIMIT =
50
- SLUG_LIMIT =
50
- SLUG_PATTERN =
/\A[a-z][-_a-z0-9]*[a-z]\z/i
- SLUG_PATTERN_HTML =
'^[a-zA-Z][-_a-zA_Z0-9]*[a-zA-Z]$'
- TITLE_LIMIT =
255
- TEXT_LIMIT =
5000
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.entity_parameters ⇒ Object
41 42 43 |
# File 'app/models/editable_block.rb', line 41 def self.entity_parameters %i[body description footer image language_id lead name raw_output slug title visible] end |
.localized_block(slug, language_code) ⇒ Object
35 36 37 38 39 |
# File 'app/models/editable_block.rb', line 35 def self.localized_block(slug, language_code) language = Language.find_by(code: language_code) criteria = { visible: true, slug: slug } find_by(criteria.merge(language: language)) || find_by(criteria) end |
Instance Method Details
#editable_by?(user) ⇒ Boolean
46 47 48 |
# File 'app/models/editable_block.rb', line 46 def editable_by?(user) UserPrivilege.user_has_privilege?(user, :content_manager) end |