Module: StaticBlocks::StaticBlocksHelper

Defined in:
lib/static_blocks/helpers.rb,
app/helpers/static_blocks/static_blocks_helper.rb

Instance Method Summary collapse

Instance Method Details

#static_block_for(title, default = nil) ⇒ Object Also known as: s



3
4
5
6
7
8
9
10
11
12
# File 'lib/static_blocks/helpers.rb', line 3

def static_block_for(title, default = nil)
  Rails.cache.fetch("static_block::"+I18n.locale.to_s+"::"+title.to_s) do
    static_block = StaticBlock.published.find_by_title(title.to_s)
    if static_block
      static_block.content
    else
      "StaticBlock for #{title.to_s} missing"
    end
  end
end

#static_block_published?(title) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/static_blocks/helpers.rb', line 14

def static_block_published?(title)
  Rails.cache.fetch("static_block::"+I18n.locale.to_s+"::"+title.to_s) do
    StaticBlock.published.find_by_title(title.to_s) || false
  end
end