最新 Rails 3:ActionView::Template::Error(无法解析第 105 行第 13 列的 YAML)

发布于 2024-10-16 13:55:02 字数 1293 浏览 6 评论 0原文

我最近在 Rails 3 中遇到了一个奇怪的问题,可能是自从新的 ruby​​gems 1.5 更新以来。基本上,当我使用乘客 3.0.2 将程序部署到 nginx 时,我立即有 500 个页面,并且在我的生产日志中出现如下问题:


ActionView::Template::Error (couldn't parse YAML at line 105 column 13):
    10: </div>
    11: <% end %>
    12: <div class="field">
    13:     <%= f.label :name %> <%= f.text_field :name %>
    14: </div>
    15: <div class="field">
    16:     <%= f.label :password %> <%= f.password_field :password %>
  app/views/sessions/new.html.erb:13:in `block in _app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
  app/views/sessions/new.html.erb:5:in `_app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'

看起来环境中缺少某些内容,因此它无法识别我的所有 form_for 元素。基本上,该页面只是一个简单的登录页面,有 2 个字段 - 名称和密码。其他带有表单的页面也会出现此问题,但仅限于生产环境。在开发环境中,它完全工作正常。我已经将所有gems升级到最新版本,包括rails 3.0.4,但是看起来与这个问题不太相关。在 gem 1.5 之前,我也曾经在我的 VMware 上的 ubuntu 上部署过同样的东西,现在一切都还好,但是新的部署已经没有回头路了。

我已经将其部署到两台运行最新ubuntu的机器上,两台机器都有这样的错误。 Nginx 和乘客按照标准步骤安装。显然,由于这个问题,该网站永远无法运行。任何人都可以为此提供任何错误修复吗?如果可以的话非常感谢!

PS:我写的登录页面基本上来自这里: http://railstutorial.org/chapters/sign-in-sign-out#top

I have recently encountered into a weird problem or Rails 3, possibly ever since the new rubygems 1.5 update. Basically when I deploy my program to nginx with passenger 3.0.2, I have 500 page immediately and problems like this in my production log:


ActionView::Template::Error (couldn't parse YAML at line 105 column 13):
    10: </div>
    11: <% end %>
    12: <div class="field">
    13:     <%= f.label :name %> <%= f.text_field :name %>
    14: </div>
    15: <div class="field">
    16:     <%= f.label :password %> <%= f.password_field :password %>
  app/views/sessions/new.html.erb:13:in `block in _app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
  app/views/sessions/new.html.erb:5:in `_app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'

It looks like it's missing something in the environment and so it can't recognize all of my form_for elements. Basically the page is just a simple login page with 2 fields - name and password. This problem also happens for other pages with forms, but only in production environment. In development environment, it's totally working fine. I have upgraded all my gems to the latest version, including rails 3.0.4, which however looks like not quite related to this problem. I also used to deploy the same thing onto the ubuntu on my VMware BEFORE gem 1.5, everything is still fine now, however there's no turning back for the new deployments.

I have deployed this to 2 machines running latest ubuntu, and both machine have such errors. Nginx and passenger are installed with the standard steps. Obviously with this problem the site can never run. Can anyone provide any bug fix for this? Thanks very much if you could!

PS: the login page I wrote is basically from here:
http://railstutorial.org/chapters/sign-in-sign-out#top

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

缘字诀 2024-10-23 13:55:02

我将以下两行添加到 config/boot.rb 文件中,问题得到解决。

require 'yaml'
YAML::ENGINE.yamler= 'syck'

I added the following two lines to the config/boot.rb file and the problem was solved.

require 'yaml'
YAML::ENGINE.yamler= 'syck'
梅窗月明清似水 2024-10-23 13:55:02

我也有同样的问题。实际上我只需要第一行:

require 'yaml'

不需要专门设置 YAML::Engine。

I had the same problem. Actually I only needed the first line:

require 'yaml'

No need to set the YAML::Engine specifically.

酒与心事 2024-10-23 13:55:02

对于 yaml 语法问题,TextMate 中的“查看/显示不可见项”等选项可能非常有助于定位语法问题,yaml 对此非常敏感。
就我而言,我只需将所有语言环境文件中的所有制表符替换为空格即可。
另请注意,如果同一级别上没有同名的节点。

For a problems with yaml syntax options like 'View/Show invisibles' in TextMate may be very helpful to locate syntax problems, yaml is very sensitive about it.
In my case I just had to replace all tabs with spaces in all locale files.
Also notice, if you don't have nodes with the same name on same level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文