pyro_lemur
pyro_lemur

Reputation: 104

Ruby on Rails error handling

In my production Ruby on Rails app, a 500 error page will show the source code of the controller where the error occurred. Obviously these errors should be handled in the first place, but I am dealing with a ton of legacy code.

Is there a way to create a custom error page that will not reveal my source code when an error is thrown?

Upvotes: 0

Views: 75

Answers (1)

Simple Lime
Simple Lime

Reputation: 11060

In you development.rb general configuration of your app, there's a flag

config.consider_all_requests_local = true

which is true, by default, in development. If you set that to false (the default in production), you can see the error page that users will see in your production app. This page is in public/500.html and public/404.html if you want to customize those.

You can also search around for ways to have Rails use ERB to create a custom error page, there are lots of tutorials on that, but I haven't used any and thus can't recommend one.

Upvotes: 1

Related Questions