Sha256: 8ac0c45a0441a658375721aaebb0a0a43db0b2b9b584a53c13dd3856f21d9d40

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

class ItemsController < ApplicationController

  before_filter :related

  def index
    behavior_cache do
      @items = Item.find(:all)
    end
    render :action => 'list'
  end
  
  def detail
    # Nesting is theoretically useful when the outer view block invalidates faster than the inner one
    behavior_cache :tag => :outer do
      @items = Item.find(:all)
    end
    behavior_cache Item => :id, :tag => :inner do
      @item = Item.find(params[:id])
    end
  end
  
  def show
    behavior_cache Item => :id do
      @item = Item.find(params['id'])
    end
  end
  
  def recent
    behavior_cache nil, :tag => [:seconds] do
      @items = Item.find(:all, :conditions => ['updated_at >= ?', params['seconds'].to_i.ago])
    end
  end
  
  def preview
    @perform = false
    behavior_cache Item => :id, :perform => @perform do
      @item = Item.find(params['id'])
    end
    render :action => 'show'
  end
  
  private
  
  def related
    behavior_cache :ignore => :all, :tag => 'related' do
      @related = "Delicious cake"
    end
  end
    
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
interlock-1.4 test/integration/app/app/controllers/items_controller.rb
interlock-1.1 test/integration/app/app/controllers/items_controller.rb
interlock-1.2 test/integration/app/app/controllers/items_controller.rb
interlock-1.3 test/integration/app/app/controllers/items_controller.rb