How to disable explicit stack traces on Ruby on Rails website - ruby-on-rails

I have a Ruby on Rails Spree commerce app where I have explicit stack traces enabled in production (e.g., instead of the "We're sorry but something went wrong" message there is a long stack trace with developer-friendly and user unfriendly information).
I remember that I activated this to see what went wrong in production, but now I want to disable it again. Unfortunately I cannot find nor remember how to do this.
I hope someone can tell me how to configure my app to redirect to the standard 500 and 404 pages.

Open project_root/config/environments/production.rb
And set config.consider_all_requests_local = false

Related

How to turn off the red/grey error help page tool in rails development environment?

I'm trying to replicate a bug in development which come from the production environment.
When the bug occurs I should see a 500 server error, but rails is displaying the following page to me, which is not what I want:
the grey rails error page
(the error in the image is not the one I'm trying to reproduce, but it shows they error page, which is what I'm talking about here)
How can I turn off this feature from rails so it just display a 500 error that a normal user will see?
And what is this tool/page called? I usually just call it the (red) rails error page. (but in this case it is grey for some reason, I don't know why too. Does anyone know?)
Try to the following
# config/environments/development.rb
config.consider_all_requests_local = false
By default, this value is true because of the need to debug code on development environment that's why, if you change value with false then will show the error page which is designed default.
If you need to generate and design custom then the follow this tutorial.
Hope to help
What about run rails in production environment?
rails server -e production

Getting detailed errors in Rails

Somehow my local Rails app is no longer showing detailed error messages. Instead, it shows "We're sorry, but something went wrong." by default. This means I have to check the log each time. I tried forcing the server to start in development mode by running:
RAILS_ENV=development bundle exec rails s
Any ideas on how to get the error logging back?
Instead, it shows "We're sorry, but something went wrong."
This is in production, I take it? If so, this is as intended. You don't display detailed error messages (with stacktraces and sensitive data) to end users.
So yes, either watch your logs, or set up one of the many exception tracking services (honeybadger, sentry, etc.)
If you want to do it anyway (against all advice), set this in your config/environments/production.rb
config.consider_all_requests_local = true

Ruby on Rails 4 - config.consider_all_requests_local = true in production

In config/environments/production.rb I can set config.consider_all_requests_local = true to be able to see the errors with good info for debugging, but this will also show the error to users.
In production ENV how is it possible to add config.consider_all_requests_local = true Only for my IP address while others see 404 or 500 error?
Or is it any work around for it?
PS: I am using ruby on rails 4.2.4
For staging and production envs I prefer using https://github.com/errbit/errbit paired with https://airbrake.io/ service (with free plan) to collect and process all errors.
I'm not sure it's the best way to go to solve your errors.
You should temporary lower your config.log_level to :debug to see all details about your errors, solve it, then set it back to :info.
You can also use any tracking tool of your application bugs as papertrail, airbrake or new_relic, to monitor your app and analyse your logs.
The standard way to do this would be to either use a staging server and reproduce any error there and/or use a service such as Airbrake or Bugsnag to record all the details of the error without exposing them to the user.
Rails itself does not include any functionality to do what you want. You could probably write a Rack middleware that allows you to do exactly what you want though. You can have a look at https://github.com/charliesome/better_errors, they allow you to whitelist IPs out of the box it looks like. Their code is likely to be good reading if you which to go at it alone as well so ...

Rails annoying message We're sorry, but something went wrong

****We're sorry, but something went wrong.
If you are the application owner check the logs for more information.****
On various rails applications I have been getting this all the time. How can this be fixed for good on ruby on rails apps?
You will have to check the log and fix the error, for production application you can use services like airbreak or errbit a free solution. Whenever this page occurs you will receive full trace and error. Hope this will help you in making application much more stable.

How to set a custom error page with passenger and apache

I am using Capistrano,Apache 2 and Passenger to rollout my rails applications on a weekly basis, this works well. Recently I encountered an error where the passenger side of the deployment exposed my stack trace and my server information, I was able to do a rollback and it was only exposed for a moment, but a moment is still venerable.
So:
How do I disable this?, I have see this so that might answer that question but it leads to more:
I want to use some Rails Custom error pages to display errors for all the 500's and the 404, essentially if passenger explodes or you encounter a broken route (so a rails error) I want you to see a custom error page, not a rails error page, not a passenger error page.v I was reading this documentation on passenger and apache but it didn't provide any examples of how you might do this.
My goal is that if for some reason you encounter a rails error or a deployment goes wrong that you don't see the rails stack trace or the passenger stack trace. that you see, instead, a custom error page.
Nice thing to do during a deployment process is to redirect any requests to a static page saying "We'll be back in 10 minutes". You can follow this answer to do it manually or use a gem capistrano/maintenance. The idea is that you'd have a capistrano task. By running this task a static html page is being created on the server in public directory. Apache is configured to watch whether this page exists, and if it does - all requests are redirected to it with 503 status.

Resources