Class: MicroCms::ContentBlock
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MicroCms::ContentBlock
- Defined in:
- app/models/micro_cms/content_block.rb
Class Method Summary collapse
- .content_block_for_path(path, content: '') ⇒ Object
- .format_path(i18n_key) ⇒ Object
- .table_name_prefix ⇒ Object
Instance Method Summary collapse
Class Method Details
.content_block_for_path(path, content: '') ⇒ Object
16 17 18 19 20 |
# File 'app/models/micro_cms/content_block.rb', line 16 def self.content_block_for_path(path, content: '') ContentBlock.find_or_create_by(path: format_path(path)) do |content_block| content_block.content = content end end |
.format_path(i18n_key) ⇒ Object
12 13 14 |
# File 'app/models/micro_cms/content_block.rb', line 12 def self.format_path(i18n_key) "#{i18n_key.parameterize}-#{I18n.locale}" end |
.table_name_prefix ⇒ Object
8 9 10 |
# File 'app/models/micro_cms/content_block.rb', line 8 def self.table_name_prefix 'micro_cms_' end |
Instance Method Details
#to_param ⇒ Object
22 23 24 |
# File 'app/models/micro_cms/content_block.rb', line 22 def to_param path end |