Last active
December 19, 2015 03:29
-
-
Save rtsinani/5890442 to your computer and use it in GitHub Desktop.
Rails 3.2 ceate static pages with page_cache and rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorsController < ApplicationController | |
caches_page :show | |
def show | |
# create 404.html.erb, etc in errors/views | |
render params[:id] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match '/:id' => 'errors#show' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment