Skip to content

Instantly share code, notes, and snippets.

@rtsinani

rtsinani/cache.rake

Last active Dec 19, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.