简体   繁体   English

在RoR视图中获取{{attribute}} {{message}}

[英]getting {{attribute}} {{message}} in RoR views

Login 1 error prohibited this {{model}} from being saved 登录1错误禁止此{{model}}被保存

There were problems with the following fields: 以下字段存在问题:

  • {{attribute}} {{message}} {{attribute}} {{message}}

this is the view code 这是视图代码

    <h1>Login</h1>

    <% form_for @user_session, :url => user_session_path do |f| %>
      <%= f.error_messages %>
      <%= f.label :login %><br />
      <%= f.text_field :login %><br />
      <br />
      <%= f.label :password %><br />
      <%= f.password_field :password %><br />
      <br />
      <%= f.check_box :remember_me %><%= f.label :remember_me %><br />
      <br />
      <%= f.submit "Login" %>
    <% end %>

` its odd and it shows up on in the time_ago_in_words method when the out put is in months “它很奇怪,当输出数月时,它会在time_ago_in_words方法中显示出来

just kinda started doing this randomly, anybody seen this before? 只是有点开始随机做这个,以前有人见过吗?

Yes, it happens when the version of Ruby has been upgraded to a version that is not supported by your version of Rails. 是的,当Ruby的版本升级到您的Rails版本不支持的版本时,就会发生这种情况。 Older version of rails uses a syntax that is not supported by newer versions of Ruby. 较旧版本的rails使用较新版本的Ruby不支持的语法。

To solve it, you should either upgrade Rails or downgrade Ruby. 要解决它,您应该升级Rails或降级Ruby。

Rails 2.3.9 should be sufficient. Rails 2.3.9就足够了。

http://weblog.rubyonrails.org/2010/9/4/ruby-on-rails-2-3-9-released http://weblog.rubyonrails.org/2010/9/4/ruby-on-rails-2-3-9-released

the i18n gem needs to correspond to the version of RUBY and RAILS that you're running ... i18n gem需要与您正在运行的RUBY和RAILS版本相对应...

changelog for i18n. 更改日志为i18n。 http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/ http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/

running 赛跑

gem uninstall i18n

then 然后

gem install i18n -v 0.4.0

should solve any issues you've got with rails 2.3.8 and the double curly bracket error messages 应该解决你使用rails 2.3.8和双花括号错误消息所遇到的任何问题

You can also run into this if you install the i18n gem. 如果你安装了i18n gem,你也可以遇到这种情况。 I had installed metrical, and one of its dependencies is the i18n gem. 我已经安装了metrical,其中一个依赖项是i18n gem。 This caused the same error as above. 这导致了与上述相同的错误。 Once I removed the gem, I started seeing the correct messages again. 一旦我删除了gem,我就开始再次看到正确的消息。

cd <yourRailsProject> 
gem install i18n -v 0.4.0 -i vendor/ -V

to install the i18n gem into the vendor folder (-V for verbose output, just to see what's going on under the hood) 将i18n gem安装到vendor文件夹中(-V用于详细输出,只是为了查看引擎盖下发生了什么)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM