How many times do you find yourself doing something like this:
Ugh! Ugly and not very DRY!
Instead, create a file called datetime_format.rb in your config/initializers folder. Put the following snippet into that file:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( :year_month_day => '%Y-%m-%d', :year_month_day_and_time => '%Y-%m-%d %H:%M' )
Now, instead of that ugly line above, you can use the following:
Ah, much better. We now have readable maintainable date formats all defined in a single place.