-
-
Save kirs/5599184 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
namespace :app do | |
namespace :error_pages do | |
desc "Generates static pages 500, 403, 404, 422" | |
task :generate => :environment do | |
av = ActionView::Base.new | |
av.class_eval do | |
include ApplicationHelper | |
include Rails.application.routes.url_helpers | |
end | |
file = Rails.root.join("app", "views", "layouts", "error_page.html.haml") | |
[500, 403, 404, 422].each do |code| | |
puts "Generate public/#{code}.html" | |
page = File.join(Rails.public_path, "#{code}.html") | |
File.open(page, "w") do |output| | |
output.write av.render(file: file, locals: {code: code}) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment