zachhale (owner)

Revisions

gist: 211441 Download_button fork
public
Public Clone URL: git://gist.github.com/211441.git
Embed All Files: show embed
generate_static_pages.rake #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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