Skip to content

Instantly share code, notes, and snippets.

@shah743
Created February 10, 2016 12:01
Show Gist options
  • Save shah743/e1c9b62de9f41d52cd69 to your computer and use it in GitHub Desktop.
Save shah743/e1c9b62de9f41d52cd69 to your computer and use it in GitHub Desktop.
# config/routes.rb
%w( 404 422 500 ).each do |code|
get code, :to => "errors#show", :code => code
end
# app/views/errors/404.html.haml
%h1 404 - Not Found
class ErrorsController < ApplicationController
def show
render status_code.to_s, :status => status_code
end
protected
def status_code
params[:code] || 500
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment