Skip to content

Instantly share code, notes, and snippets.

@emiltin
Created June 28, 2012 10:10
Show Gist options
  • Select an option

  • Save emiltin/3010444 to your computer and use it in GitHub Desktop.

Select an option

Save emiltin/3010444 to your computer and use it in GitHub Desktop.
#config/application.rb
config.exceptions_app = self.routes
#config/routes.rb
match "/404.:format", :to => "application#error_route_not_found"
#app/controllers/application.rb
def error_route_not_found
respond_to do |format|
format.html { render 'errors/route_not_found', :status => :not_found }
format.any { render :nothing => true, :status => :not_found }
end
end
#command line
> curl "http://www.localhost:3000/nowhere.xml" => # bunch of html.. only want to return the status code when the format is not html!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment