Class: GacoCms::Page
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- GacoCms::Page
- Includes:
- BuddyTranslatable, FieldsAssignable
- Defined in:
- app/models/gaco_cms/page.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#all_field_groups ⇒ Object
TODO: deprecated.
- #the_content(cache: true) ⇒ Object
Methods included from FieldsAssignable
#the_grouped_values, #the_value, #the_values
Methods inherited from ApplicationRecord
#activestorage_url, #cache_key_locale, human_name
Class Method Details
.by_key(key) ⇒ Object
37 38 39 |
# File 'app/models/gaco_cms/page.rb', line 37 def self.by_key(key) where_key_with(key).take end |
Instance Method Details
#all_field_groups ⇒ Object
TODO: deprecated
42 43 44 |
# File 'app/models/gaco_cms/page.rb', line 42 def all_field_groups FieldGroup.union_scope(field_groups, page_type.field_groups) end |
#the_content(cache: true) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/gaco_cms/page.rb', line 46 def the_content(cache: true) callback = proc do tpl = template.presence || page_type.template.to_s tpl = "[page_content]#{tpl}" unless tpl.include?('[page_content]') ShortcodeParser.call(tpl, self).to_s end return callback.call unless cache Rails.cache.fetch(cache_key_locale(:the_content), expires_at: Time.current.end_of_day, &callback) end |