Default Date Format in Rails (Need it to be ddmmyyyy)

ruby-on-rails

Solution

In your settings file: config/environment.rb"

my_date_formats = { :default => '%d/%m/%Y' } 

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

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(my_date_formats) 

source: http://thedevelopercorner.blogspot.com/2009/03/change-default-date-format-in-ruby-on.html

Problem

I've been working with a rails form all day and I was just randomly testing it and tried the date 25/12/2009 and it came up with a huge error. It was at this point I realised that rails is set to american date mode (mm/dd/yyyy) instead of the UK style: dd/mm/yyyy. How can I set rails to automatically deal with all dates in dd/mm/yyyy format?

Original source

Related problems