Rails 3:“文件类型 yml 未知”当尝试访问 basic _form.html.erb 时
我正在尝试编写一个非常基本的 Rails 应用程序,但是每当我编写最简单的形式时,我都会收到以下错误:
I18n::UnknownFileType in Posts#add
Showing /home/john/Websites/sandbox/rails-messing/app/views/posts/_form.html.erb where line #14 raised:
can not load translations from /usr/local/rvm/gems/ruby-head/gems/activesupport-3.0.0.beta4/lib/active_support/locale/en.yml, the file type yml is not known
Extracted source (around line #14):
11: <% end %>
12:
13: <div class='field'>
14: <%= f.label :title %><br />
15: <%= f.text_field :title %>
16: </div>
17: <% end %>
Trace of template inclusion: app/views/posts/add.html.erb
Rails.root: /home/john/Websites/sandbox/rails-messing
Application Trace | Framework Trace | Full Trace
app/views/posts/_form.html.erb:14:in `block in _render_template__2621936652101774794_37048540__1740943893204605353'
app/views/posts/_form.html.erb:1
app/views/posts/add.html.erb:1
app/controllers/posts_controller.rb:27:in `add'
知道发生了什么吗? locale/en.yml 文件就在那里 &未受影响。安装的其余部分似乎工作正常。表单只是基本的脚手架生成的东西。具体来说:
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id='error_messages'>
<h2><%= pluralize(@post.errors.count, "error") %> prevented this form from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class='field'>
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<% end %>
任何想法都非常感谢 - 我完全被难住了。
I'm trying to write up a very basic rails app, but any time I write up even the simplest form I get the following error:
I18n::UnknownFileType in Posts#add
Showing /home/john/Websites/sandbox/rails-messing/app/views/posts/_form.html.erb where line #14 raised:
can not load translations from /usr/local/rvm/gems/ruby-head/gems/activesupport-3.0.0.beta4/lib/active_support/locale/en.yml, the file type yml is not known
Extracted source (around line #14):
11: <% end %>
12:
13: <div class='field'>
14: <%= f.label :title %><br />
15: <%= f.text_field :title %>
16: </div>
17: <% end %>
Trace of template inclusion: app/views/posts/add.html.erb
Rails.root: /home/john/Websites/sandbox/rails-messing
Application Trace | Framework Trace | Full Trace
app/views/posts/_form.html.erb:14:in `block in _render_template__2621936652101774794_37048540__1740943893204605353'
app/views/posts/_form.html.erb:1
app/views/posts/add.html.erb:1
app/controllers/posts_controller.rb:27:in `add'
Any ideas what's going on? The locale/en.yml file is there & untouched. The rest of the install seems to work fine. The form is just basic scaffold-generated stuff. Specifically:
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id='error_messages'>
<h2><%= pluralize(@post.errors.count, "error") %> prevented this form from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class='field'>
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<% end %>
Any ideas much appreciated - I'm completely stumped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以防万一有人遇到同样的问题:
我忘记了我在 RVM 中运行 ruby-pre,而且最新的 1.9.3 pre 似乎在 YAML 解释器方面存在问题。我将项目恢复到 1.9.2 候选版本(它原本应该在的位置),一切都解决了。希望这有帮助。 ;-)
Just in case anyone has the same problem:
I forgot I was running ruby-pre in RVM, and it seems the latest 1.9.3 pre had problems with the YAML interpreter. I reverted the project to 1.9.2 release candidate (Where it should have been in the first place) and everything was solved. Hope this helps. ;-)