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
For people interested to format in a specific location and not all over the project, several answers advised to check if null and I want to add that using try with strftime will help to make it shorter.
<%= f.fields_for :assets_depreciations do |asset| %>
<%= asset.text_field :depreciation_date, value: asset.object.depreciation_date.try(:strftime, "%d-%m-%Y") %>
<% end %>