I don’t like how I’m repeating myself with the strftime bit.
Is there some shorter Time method to format time for a (MySQL) datetime
field that I’ve missed? The magic of created_at/updated_at does not seem
to work with fixtures.
Assuming I want to avoid repeating myself, in what file would I add a
helper method for this, or extend the Time class with a method?
Apparently not test_helper - “undefined local variable or method”.
On Sat, Jan 07, 2006 at 11:21:04AM +0100, Henrik wrote:
Is there some shorter Time method to format time for a (MySQL) datetime
field that I’ve missed? The magic of created_at/updated_at does not seem
to work with fixtures.
You can add custom Time and Date strftime formats by adding key/value
pairings (in e.g. your config/environment.rb) to the
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS and
ActiveSupport::CoreExtensions::Conversions::DATE_FORMATS hashes.
For example:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!
:day => ‘%Y-%m-%d’
marcel
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.