Sha256: 96aa765a08947e76d8de1ae32eb902580c25486f280622de01ceeee4305b6a1c

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

class TableController < ApplicationController
  caches_page :index, :table
  def index
    expires_in TableSetter::App.cache_timeout.minutes
    if stale? :last_modified => Table.fresh_yaml_time, :public => true
      @tables = Table.all
    end
  end
  
  def table
    @table = Table.new(params[:slug])
    expires_in TableSetter::App.cache_timeout.minutes
    if stale? :last_modified => Time.parse(@table.updated_at), :public => true
      @table.load
      page = params[:page] || 1
      @table.paginate! page
    end
  end
  
  def expire
    table = Table.new(params[:slug])
    cache_dir = ActionController::Base.page_cache_directory
    FileUtils.rm_r(Dir.glob(cache_dir + "/#{table.slug}.html")) rescue Errno::ENOENT
    FileUtils.rm_r(Dir.glob(cache_dir + "/#{table.slug}")) rescue Errno::ENOENT
    redirect_to :action => :index
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_setter_generator-0.1.0 templates/table_controller.rb