Ruby 在 Rails 4 - config.consider_all_requests_local = 在生产中为真
Ruby on Rails 4 - config.consider_all_requests_local = true in production
在 config/environments/production.rb
中,我可以设置 config.consider_all_requests_local = true
以便能够查看错误并提供良好的调试信息,但这也会向用户显示错误。
在 production ENV
中如何添加 config.consider_all_requests_local = true
仅适用于我的 IP 地址 而其他人看到 404 或 500 错误?
或者有什么变通办法吗?
PS:我在 rails 4.2.4
上使用 ruby
我不确定这是解决错误的最佳方法。
您应该 临时 将您的 config.log_level
降低到 :debug
以查看有关您的错误的所有详细信息,解决它,然后将其设置回 :info
.
您还可以使用任何应用程序错误跟踪工具(如 papertrail、airbrake 或 new_relic)来监控您的应用程序并分析您的日志。
对于暂存和生产环境,我更喜欢使用 https://github.com/errbit/errbit paired with https://airbrake.io/ 服务(免费计划)来收集和处理所有错误。
执行此操作的标准方法是使用暂存服务器并在那里重现任何错误and/or使用诸如 Airbrake 或 Bugsnag 之类的服务来记录错误的所有详细信息,而不会将它们暴露给用户。
Rails 本身不包含任何您想要的功能。你可能会写一个 Rack 中间件,它允许你做你想做的事。你可以看看 https://github.com/charliesome/better_errors,它们允许你开箱即用地将 IP 列入白名单。他们的代码可能是很好的读物,如果你也想单独阅读的话......
在 config/environments/production.rb
中,我可以设置 config.consider_all_requests_local = true
以便能够查看错误并提供良好的调试信息,但这也会向用户显示错误。
在 production ENV
中如何添加 config.consider_all_requests_local = true
仅适用于我的 IP 地址 而其他人看到 404 或 500 错误?
或者有什么变通办法吗?
PS:我在 rails 4.2.4
上使用 ruby我不确定这是解决错误的最佳方法。
您应该 临时 将您的 config.log_level
降低到 :debug
以查看有关您的错误的所有详细信息,解决它,然后将其设置回 :info
.
您还可以使用任何应用程序错误跟踪工具(如 papertrail、airbrake 或 new_relic)来监控您的应用程序并分析您的日志。
对于暂存和生产环境,我更喜欢使用 https://github.com/errbit/errbit paired with https://airbrake.io/ 服务(免费计划)来收集和处理所有错误。
执行此操作的标准方法是使用暂存服务器并在那里重现任何错误and/or使用诸如 Airbrake 或 Bugsnag 之类的服务来记录错误的所有详细信息,而不会将它们暴露给用户。
Rails 本身不包含任何您想要的功能。你可能会写一个 Rack 中间件,它允许你做你想做的事。你可以看看 https://github.com/charliesome/better_errors,它们允许你开箱即用地将 IP 列入白名单。他们的代码可能是很好的读物,如果你也想单独阅读的话......