Rails 3:尝试访问基本 _form.html.erb 时,“文件类型 yml 未知" [英] Rails 3: 'The file type yml is not known' when trying to access basic _form.html.erb

查看:39
本文介绍了Rails 3:尝试访问基本 _form.html.erb 时,“文件类型 yml 未知"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个非常基本的 Rails 应用程序,但每次编写即使是最简单的形式时,也会出现以下错误:

 I18n::UnknownFileType in Posts#add显示/home/john/Websites/sandbox/rails-messing/app/views/posts/_form.html.erb 其中第 14 行提出:无法从/usr/local/rvm/gems/ruby-head/gems/activesupport-3.0.0.beta4/lib/active_support/locale/en.yml 加载翻译,文件类型 yml 未知提取的源代码(围绕第 14 行):11:<%结束%>12:13:<div class='field'>14:<%= f.label :title %><br/>15:<%= f.text_field :title %>16:</div>17:<%结束%>模板包含的痕迹:app/views/posts/add.html.erbRails.root:/home/john/Websites/sandbox/rails-messing应用程序跟踪 |框架跟踪 |完整跟踪app/views/posts/_form.html.erb:14:in `block in _render_template__2621936652101774794_37048540__1740943893204605353'app/views/posts/_form.html.erb:1应用程序/视图/帖子/add.html.erb:1应用程序/控制器/posts_controller.rb:27:in`添加'

知道发生了什么吗?locale/en.yml 文件在那里 &未受影响.其余的安装似乎工作正常.表单只是基本的脚手架生成的东西.具体:

<%= form_for(@post) do |f|%><% 如果@post.errors.any?%><div id='error_messages'><h2><%=pluralize(@post.errors.count, "error") %>阻止保存此表单:</h2><ul><% @post.errors.full_messages.each 做 |msg|%><li><%=msg%></li><%结束%>

<%结束%>

<%= f.label :title%><br/><%= f.text_field :title %>

<%结束%>

非常感谢任何想法 - 我完全被难住了.

解决方案

以防万一有人遇到同样的问题:

我忘记了我在 RVM 中运行 ruby​​-pre,而且最新的 1.9.3 pre 似乎与 YAML 解释器有问题.我将项目恢复到 1.9.2 候选版本(它应该放在首位),一切都解决了.希望这可以帮助.;-)

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.

解决方案

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. ;-)

这篇关于Rails 3:尝试访问基本 _form.html.erb 时,“文件类型 yml 未知"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆