Class: ContentStorage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ContentStorage
- Includes:
- TranslationCms::WhiteList
- Defined in:
- app/models/content_storage.rb
Overview
Schema Information
Table name: content_storages
id :integer not null, primary key
title_translations :hstore default({})
content_translations :hstore default({})
params :hstore default({})
key :string(100) not null
cacheable :boolean default(FALSE)
type_id :integer not null
created_at :datetime not null
updated_at :datetime not null
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.get(key) ⇒ Object
29 30 31 32 33 |
# File 'app/models/content_storage.rb', line 29 def get(key) return if key.blank? find_by(key: key) end |
Instance Method Details
#content! ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/content_storage.rb', line 42 def content! return content unless persisted? Rails.cache.fetch "content_storage_#{key}_#{I18n.locale}", expires_in: 4.hours do content end end |
#type_title ⇒ Object
36 37 38 39 40 |
# File 'app/models/content_storage.rb', line 36 def type_title return if type.blank? type.title end |