Class: MicroCms::ContentBlock

Inherits:
ApplicationRecord show all
Defined in:
app/models/micro_cms/content_block.rb

Class Method Summary collapse

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_prefixObject



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_paramObject



22
23
24
# File 'app/models/micro_cms/content_block.rb', line 22

def to_param
  path
end