Skip to content

Instantly share code, notes, and snippets.

@rtsinani
Last active December 19, 2015 03:29
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 rtsinani/5890442 to your computer and use it in GitHub Desktop.
Save rtsinani/5890442 to your computer and use it in GitHub Desktop.
Rails 3.2 ceate static pages with page_cache and rake
desc 'Generate the static pages'
task :cache => :environment do
pages = %w(404 422 500)
app = Rails.application
app.config.action_controller.perform_caching = true
session = ActionDispatch::Integration::Session.new(app)
pages.each { |page| puts session.get("/#{page}") }
end
class ErrorsController < ApplicationController
caches_page :show
def show
# create 404.html.erb, etc in errors/views
render params[:id]
end
end
match '/:id' => 'errors#show'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment