开发者

Rails DATE_FORMATS initializers causing error

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?


In Rails 3 you can just use

Time::DATE_FORMATS.merge!(...)

instead of the Rails 2 format of:

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(...)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜