Skip to content

Instantly share code, notes, and snippets.

@zachhale
Created October 16, 2009 00:43
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 zachhale/211441 to your computer and use it in GitHub Desktop.
Save zachhale/211441 to your computer and use it in GitHub Desktop.
task :generate_static_pages => :environment do
ActionController::Dispatcher.define_dispatcher_callbacks(true) # same as config.cache_classes = true
class PreGenerateController < ApplicationController
layout 'secure'
def show
render :action => params[:id]
end
end
require 'action_controller/integration'
ActionController::Routing::Routes.add_route 'pre_generate/:id',
:controller => 'pre_generate', :action => 'show'
app = ActionController::Integration::Session.new
%w(404 422 500).each do |action|
app.get "/pre_generate/#{action}"
File.open("public/#{action}.html", "w") { |f| f.write app.response.body }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment