I've just recently upgraded from Rails 3.0.9 to 3.2.8 and I am seeing user-friendly error pages for my errors instead of the usual error messages.
I've checked the following:
Ran a Rails.env and it showed I was in development
My development.rb has config.consider_all_requests_local = true
I've searched on google and couldn't find anything else. Is there anything else I'm missing here?
Thanks!
As said in User-friendly error pages not displaying in production environment
The other criteria for showing the errors is request.local?
So maybe your ip is not showing as a local one to rails (i.e. you are using a proxy). If so or request.local? is not true you could try the patch mentioned in above question (but of course return true and not false ;)
Related
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
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 ...
I'm having big problems with finding what is causing my rails app to return 500 internal error when I call a controller action. I tried setting the config.log_level = :debug in the production.rb environment, but rails won't write display or write any details about the error in the production.log.
If I run the same app and do the same action on my local machine in development mode, I don't get any error.
How should I reveal what is causing the error? I also tried using errorapp.com but no error will be reported there..
Thanks for help
I use the exception_notification gem link
in all my rails apps. When configured with the mail settings it will email you when an exception occurs with the error info.
In my rails 3.1 app, I do have
config.action_mailer.raise_delivery_errors = true
in my development.rb file (and, yes, have restarted by local dev server since changing that to true).
However, as I develop new email templates and run into the occasional ActionView::Template::Error
I'm not seeing any of the debugging info being put out as to which line threw the error. (As opposed to when one of my normal app views has a problem the log shows the snippet of the haml source with the problem).
IS there a way to turn on similar debugging messages for mailers?
I use rails console instead of making a web request to test action mailer. It will gives a-lot more info if an error ocures.
$ rails c
> MyMailer::maielr_name( var1, var2 ).deliver!
I just upgraded to rails 3.2 Everything is working fine except error pages no longer show the normal development debug info. Instead it's showing the standard production error page (white background with red text in the middle:
"We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly."
Is there a new setting or something I'm missing for rails 3.2? I've read over the upgrade instructions and do not see it mentioned anywhere. I tried downgrading to 3.1.3 and the error pages work again so this is definitely a rails 3.2 issue. Thanks.
Check the config.consider_all_requests_local inside development.rb. It must be set to true in order to show full error reports.
Nicolas, I'm faced the same problem and only saw the message We're sorry, but something went wrong. and nothing in logs.
The problem was in UTF-8 characters, so adding encoding declaration to the beginning of the file solved it:
# encoding = utf-8
If neither jibiels nor Dmitrys solution helped, try out the solution mentioned here:
Rails doesnt log tempalte errors in development mode
(Maybe this also helps you, #Nicolas)