简体   繁体   English

在翻译日期上使用%d(已弃用)时出现Rails错误,我应该改用什么?

[英]Rails error when using %d (deprecated) on translating dates, what should i use instead?

In language file es.yml i have 在语言文件es.yml我有

time:
    formats:
      short: "%d %b %H:%M"

when i try using it like: 当我尝试使用它时:

<%= l my_object.created_at, :format => :short %>

it shows the following error 它显示以下错误

ActionView::TemplateError (missing interpolation argument in "%{count} %b %H:%M" ({:object=>Fri, 11 Jun 2010 09:00:00 CDT -05:00} given)) on line #68 of app/views/matches/_by_session.html.erb:  
65:               `</div>`  
66:   
67:               `<div>`  
68:                       `<%= l match.starts_at, :format => :short %>`  
69:               `</div>`  
70:  
71:             `</div>`  

How should I display the day... if %d doesnt work anymore.... Any ideas??? 我应该如何显示日期...如果%d不再起作用...。有什么想法吗???

I ran into this problem and it took me ages to work it out. 我遇到了这个问题,我花了很长时间才解决。

For me the problem was I also had Rails version 3 beta installed and a prerequisite for that is the I18n gem. 对我来说,问题是我还安装了Rails 3 beta版,而这的前提是I18n gem。

This is not required for version 2.* of rails and simply uninstalling this gem (I18n) resolved my issues. 2. *版的rails不需要此功能,只需卸载此gem(I18n)就可以解决我的问题。

Yep indeed i had the same kind of error: 是的,的确我有同样的错误:

I18n::MissingInterpolationArgument in Admin/campaigns#index
Showing app/views/admin/campaigns/_campaign.html.erb where line #3 raised:
missing interpolation argument in "%Y/%m/%{count}" ({:object=>Mon, 19 Jul 2010 15:15:57 CEST +02:00} given)

Uninstalling the i18n gem fixed it 卸载i18n gem可以修复它

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

相关问题 Rails中脚手架的用例有哪些? 我应该何时使用而不使用它? - What are the use cases of scaffolding in Rails? When should I use and not use it? 使用rails presenters - memoizable在3.1中被弃用 - 使用|| =而不是? - Using rails presenters - memoizable getting deprecated in 3.1 - use ||= instead? 在 Rails 5+ 中使用 RSpec 时,我应该用什么来代替“赋值”? - What should I use in place of “assigns” when using RSpec with Rails 5+? 为什么在Rails中使用to:而不是:to =&gt;时会出错? - Why do I get error when I use to: instead of :to => in rails? 不推荐使用Modernizr.load,我应该使用什么? - Modernizr.load deprecated, what should I use? RAILS我应该使用什么样的关系? - RAILS What kind of relation should I use? Rails)我现在应该使用什么Markdown? - Rails) What Markdown Should I Use Now? Rails - 我应该使用什么进行搜索? - Rails - What Should I use for Search? Rails 3.2:什么时候应该使用active_scaffold而不是内置支架? - Rails 3.2: When should I use active_scaffold instead of the built-in scaffold? 我应该在我的 rails3 应用程序中使用什么而不是全局变量? - what should i be using instead of a global variable in my rails3 app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM