The only reason you get the 500 code is because your application throws an exception. This could be due to a missing route where you have nothing specific that matches this, or due to a failure of your controller or view.
In a production environment, you may want to catch all the errors generated by your application and, if necessary, show the best error screen or the "Not Found" page.
For example, the catch-all catch general exception trap can be defined as:
class ApplicationController < ActionController::Base if (Rails.env.production?) rescue_from Object, :with => :uncaught_exception_rescue end protected def uncaught_exception_rescue(exception) render(:partial => 'errors/not_found', :status => :not_found) end end
Returning a 404 error is easy if you can tell when you want to do this:
render(:partial => 'errors/not_found', :status => :not_found)
Make sure you have some default route, or you will get these errors all the time. This is usually done by adding a catch-all route at the very end of your routes. Rb:
map.default '/*path', :controller => 'default', :action => 'show'
Then you can do whatever you want with this query.
source share