I've installed Rails exception_handler and tried following the instructions to setup custom error handling, however I'm still getting the standard 500 error message that the gem creates:
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
Here's what I added to config/application.rb
:
class Application < Rails::Application
config.exception_handler = {
dev: true,
layouts: {
'500' => 'exception'
}
}
end
I created an exception layout at layouts/exception.html.erb
:
<!DOCTYPE html>
<html>
<head>
<title><%= "Error - #{@exception.status} Error" %></title>
</head>
<body>
<div class="container">
<%= yield %>
</div>
</body>
</html>
And generated the default exception views with: rails generate exception_handler:views
<div class="error">
<% if /^(5[0-9]{2})$/ =~ @exception.status.to_s %>
<!--Message -->
<%= content_tag :div, class: "message" do %>
<%= content_tag :div, class: "title" do %>
<span><%= "#{@exception.status} Error - #{details[:name]}" %></span>
<%= link_to image_tag("exception_handler/close.png"), main_app.root_url, title: "Close (Go back home)", class: "close" %>
<% end %>
<%= content_tag :div, class: "details" do %>
<%= image_tag "exception_handler/alert.png", title: "#{@exception.status} Error" %>
<div class="status"><%= @exception.status %> Error</div>
<% end %>
<%= content_tag :div, class: "info" do %>
<span><%= details[:description] %></span>
<div class="notification">
<%= link_to image_tag("exception_handler/home.png", title: "Go Back Home"), main_app.root_url, class: "home" %>
<div class="version">v<%= Rails.version %></div>
<strong>Our developers have been notified - we're working on it!</strong>
</div>
<% end %>
<% end %>
<% else %>
<%= content_tag :div, details[:description], class: "message" %>
<% end %>
</div>
I've tried restarting my rails server just to make sure the changes are taking effect, but it still doesn't work. What have I missed?