Q:

How to render 500(Internal Server Error) page using an erb instead of a static HTML in Rails?

Is there a way to have errors render a 500.html.erb file instead of the 500.html page in the public folder? I want to be able to use partials and make the page dynamic.

A:

You could take the following approach. 
1.Create a controller like app/controllers/http_errors_controller.rb
class HttpErrorsController < ApplicationController
   def internal_server_error
     render(:status => 500)
   end
end

2.Have a corresponding view - app/views/http_errors/internal_server_error.html.erb
3.Configure your routes
match "/500", :to => "http_errors#internal_server_error", :via => :all

4.Configure Rails to pick up your views instead of the default ones in the public folder. This you can achieve by adding the below line to config/application.rb
config.exceptions_app = self.routes

5.Remove the corresponding static files in the pubilc folder. public/500.html in your case.
For more on this, and its drawbacks, refer https://mattbrictson.com/dynamic-rails-error-pages
Also, there is this gem that addresses such problems stated in the above link that will acheive what you are trying to do : https://github.com/richpeck/exception_handler
Though, I would suggest against using a gem for something as simple as this.

