Reputation: 12854
I've noticed Rails implicitly handles rendering of 404 and 500 status codes and it looks for *.html in the public directory.
I was wondering if there error status error codes for 401, 403, 418 etc that you can raise that will have these handled automatically or is this something that has to be done by hand?
Upvotes: 2
Views: 2574
Reputation: 32050
If you run in production mode, 500.html,404.html,422.html files in public directory gets served whenever there respective error occured, pages from above will be shown.
In rails 3.1
We can use like below: Rails 3.1 will automatically generate a response with the correct HTTP status code (in most cases, this is 200 OK). You can use the :status option to change this:
render :status => 500
render :status => :forbidden
Rails understands both numeric and symbolic status codes.
Fore more information see this page
Cheers!
Upvotes: 1