Rails DATE_FORMATS 初始值设定项导致错误
我正在尝试使用一种广泛报道的技术。我想添加站点范围的自定义日期格式,为此,我将以下行放入 config/initializers/date_formats.rb 中:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:verbose => lambda { |time| time.strftime(
"%a, %b #{time.day.ordinalize}, %Y %I:%M %p")
}
)
请注意,这是该文件的全部内容。但在初始化时,我收到此错误:
/whatever/config/initializers/date_formats.rb:4:in `<top (required)>': uninitialized constant ActiveSupport::CoreExtensions (NameError)
我缺少什么细节?
I'm trying to use a technique widely reported as working on here. I would like to add a site-wide custom date format and in order to do so, I put the following lines in config/initializers/date_formats.rb
:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:verbose => lambda { |time| time.strftime(
"%a, %b #{time.day.ordinalize}, %Y %I:%M %p")
}
)
Note that this is the entire contents of that file. On initialization though, I get this error:
/whatever/config/initializers/date_formats.rb:4:in `<top (required)>': uninitialized constant ActiveSupport::CoreExtensions (NameError)
What detail am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Rails 3 中,您可以使用以下
格式来代替 Rails 2 格式:
In Rails 3 you can just use
instead of the Rails 2 format of: