Rails date format in a text_field

ruby-on-rails

Solution

Simple one time solution is to use `:value` option within `text_field` call instead of adding something to `ActiveRecord::Base` or `CoreExtensions`.

For example:

<%= f.text_field :some_date, value: @model_instance.some_date.strftime("%d-%m-%Y") %>

Problem

I have a rails form that displays a date in a text_field: ``` <%= form.text_field :check_in_date %> ``` The date is rendered as `yyyy-mm-dd` I'm trying to figure out how to have it display as `mm-dd-yyyy` I tried adding this config but it didn't work. ``` ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!( :default => '%m/%d/%Y' ) ```

Original source