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-m
Expanding Kamil's answer a bit: add the following method to application_helper.rb:
def date_mdY(date)
if date.nil?
""
else
date.strftime("%m-%d-%Y")
end
end
Then you can modify Kamil's answer slightly:
<%= f.text_field :some_date, :value => date_mdY(@model_instance.some_date) %>
Then you can use this helper method in any other view.
I'm using the jQuery datepicker and the date needed to be in a particular format in order for the default date to be set correctly. Thanks for the answer Kamil!