Module: CacheMachine::Helpers::CacheHelper

Defined in:
lib/cache_machine/helpers/cache_helper.rb

Instance Method Summary collapse

Instance Method Details

#cache_for(record, cacheable, options = {}, &block) ⇒ String

Returns cached EHTML content.

Examples:

Return html from cache.

= cache_for @instance, :association do
  %div= @instance.associated_records

Parameters:

  • record (ActiveRecord::Base)
  • cacheable (Symbol)
  • options (Hash) (defaults to: {})

Returns:

  • (String)


16
17
18
# File 'lib/cache_machine/helpers/cache_helper.rb', line 16

def cache_for record, cacheable, options = {}, &block
  record.fetch_cache_of(cacheable, options.merge(:format => :ehtml)) { capture &block }
end