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!(...)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.