The default date format in Ruby is yyyy-mm-dd, but I needed them to be dd/mm/yyyy in the view
I have wrote a date_format file in config/initializers
as:
Try this instead:
Time::DATE_FORMATS.merge!({:db => '%m/%d/%Y', :uk_format => '%m/%d/%Y'})
Date::DATE_FORMATS.merge!({:db => '%m/%d/%Y', :uk_format => '%m/%d/%Y'})
See: Change default Ruby Time format
Adapted my answer linked to above for the Date and format specified:
Since you're using Rails, take advantage of the I18n support: http://guides.rubyonrails.org/i18n.html#adding-date-time-formats
# config/locales/en.yml
en:
date:
formats:
default: "%d/%m/%Y"
Then you can call I18n.l Date.today
to get out a formatted date. Or in your view, you can use <%= l @foo.created_at %>
.