You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rails开发环境500错误显示生产样式,如何恢复默认开发样式?

Fixing Rails Development Environment Showing Production-Style Error Pages

Hey there, it looks like you mixed up which environment config file to edit! The production.rb file controls settings for your production environment—you need to be tweaking development.rb instead to get those nice, detailed dev error pages back.

Here's how to fix this step by step:

  • Open the right config file
    Navigate to your project's root directory and open config/environments/development.rb. This is where all your dev environment-specific settings live.

  • Verify or add these key configurations
    Look for these lines in the file (add them if they're missing entirely):

    # Treat all requests as local to display detailed development-style error pages
    config.consider_all_requests_local = true
    
    # Ensure exception details are enabled (Rails defaults this to false in dev, but double-check)
    config.action_dispatch.show_exceptions = false
    

    A quick explanation: When config.action_dispatch.show_exceptions is set to false, Rails will render the full, debug-friendly error page complete with stack traces, request parameters, and session data. If this is set to true, it'll switch to production-style error handling instead.

  • Restart your Rails server
    Configuration changes won't take effect until you restart your development server. Kill the running rails s process and start it up again to apply the new settings.

  • Check for other potential interfering factors

    • Custom exception middleware: If your project has any custom middleware that catches and handles exceptions, it might be overriding Rails' default development environment error page behavior. Try temporarily removing this middleware to test if it resolves the issue.
    • Confirm your active environment: Make sure you're actually running in development mode! By default, rails s uses the development environment, but if you've set the RAILS_ENV=production environment variable accidentally, that would cause production-style errors to show. Run echo $RAILS_ENV in your terminal to verify your current environment.

After following these steps, you should be back to seeing the detailed, developer-focused error pages you expect in your Rails development environment.

内容的提问来源于stack exchange,提问作者Bonapara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:04:57