Skip to content

Instantly share code, notes, and snippets.

@cyu
Created May 25, 2009 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyu/117328 to your computer and use it in GitHub Desktop.
Save cyu/117328 to your computer and use it in GitHub Desktop.
class ReportController < ApplicationController
after_filter :cache_weekly_report, :only => :show
def show
if params[:year]
@year = params[:year]
@month = params[:month]
@day = params[:day]
if File.exist?("#{Rails.root}/public/report/#{@year}/#{@month}/#{@day}.html")
redirect_to reports_path(:year => @year, :month => @month, :day => @day)
else
# render report for a specific day
end
else
today = Date.today
@year = today.year
@month = today.month
@day = today.day
# render report for the current week
end
end
protected
def cache_weekly_report
cache_page(response.body, "/report/#{@year}/#{@month}/#{@day}.html") if @year
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment