Rails 完整错误页面未显示视图错误 [英] Rails full error page not showing for view errors
问题描述
我有一个名为 new.html.erb
的视图,代码如下:
I have a view named new.html.erb
with the following code:
<%= some_non_existent_thing.imaginary_method %>
现在,我只看到一个简单的 500 错误页面,如下所示:
Now, I only see one simple 500 error page, like that:
500 内部服务器错误
如果您是此网站的管理员,请阅读此 Web 应用程序的日志文件和/或 Web 服务器的日志文件以找出问题所在.
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.
我不应该看到一个格式漂亮的页面,其中包含一些有关异常的信息吗?
Shouldn't I see a pretty formatted page with some information about the exception?
我不确定我在这里错过了什么,但我相信 Rails 曾经在视图中出现错误时在开发环境中显示完整的错误页面.
I'm not sure I miss something here, but I believe rails used to show the full error page in development environment when there is something wrong in the view.
推荐答案
您确定您正在运行开发环境吗?检查 RAILS_ENV=development
或您是否正在运行 rails server -e development
.
Are you sure that you are running the development environment? Check that RAILS_ENV=development
or that you are running rails server -e development
.
然后检查您的 development.rb 文件,您应该在其中包含以下行
Then check your development.rb file, you should have the following line in it
config.consider_all_requests_local = true
这篇关于Rails 完整错误页面未显示视图错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!