Skip to content

Instantly share code, notes, and snippets.

@BRMatt
Created January 5, 2015 16:59
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 BRMatt/aa383c6168f3e0abdd8f to your computer and use it in GitHub Desktop.
Save BRMatt/aa383c6168f3e0abdd8f to your computer and use it in GitHub Desktop.
Rake::Task['assets:precompile'].enhance do
assets_path = File.join(Rails.public_path, "assets")
Dir[File.join(assets_path, '*.html*')].each do |matched_asset_path|
http_status_code, extension = /#{assets_path}\/([0-9]{3})[^\/\s]*(\.html.?[^\b]*)/.match(matched_asset_path).captures
error_page_path = File.join(Rails.public_path, "#{http_status_code}#{extension}")
cp matched_asset_path, error_page_path
end
end
config.assets.paths << "#{Rails.root}/assets/html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment