title: Rails 3.1 text_field form helper and jQuery datepicker date format
body: <p>I have a form field in my Rails view like this:</p>
  
  <pre><code>&lt;%= f.text_field :date, :class =&gt; "datepicker" %&gt;
  </code></pre>
  
  <p>A javascript function converts all input fields of that class to a jQueryUI datepicker. </p>
  
  <pre><code>$(".datepicker").datepicker({
                  dateFormat : "dd MM yy",
                  buttonImageOnly : true,
                  buttonImage : "&lt;%= asset_path('iconDatePicker.gif') %&gt;",
                  showOn : "both",
                  changeMonth : true,
                  changeYear : true,
                  yearRange : "c-20:c+5"
              })
  </code></pre>
  
  <p>So far so good. I can edit the record and it persists the date correctly all the way to the DB. My problem is when I want to edit the record again. When the form is pre-populated from the record it displays in 'yyyy-mm-dd' format. The javascript only formats dates which are selected in the datepicker control. Is there any way I can format the date retrieved from the database? At which stage can I do this?</p>
  
  <p>Thanks,
  Dany.</p>
  
  <p>Some more details following the discussion below, my form is spread across two files, a view and a partial. Here's the view:</p>
  
  <pre><code>&lt;%= form_tag("/shows/update_individual", :method =&gt; "put") do %&gt;
      &lt;% for show in @shows %&gt;
          &lt;%= fields_for "shows[]", show do |f| %&gt;
              &lt;%= render "fields", :f =&gt; f %&gt;
          &lt;% end %&gt;
      &lt;% end %&gt;
      &lt;%= submit_tag "Submit"%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>And here's the <code>_fields</code> partial view:</p>
  
  <pre><code>&lt;p&gt;
      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
      &lt;%= f.date %&gt;
      &lt;%= f.label :date %&gt;
      &lt;%= f.text_field :date, :class =&gt; "datepicker" %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code>def edit_individual
      @shows = Show.find(params[:show_ids])
    end
  </code></pre>
  
  <p>I have added the following in <code>environment.rb</code>:</p>
  
  <pre><code>Date::DATE_FORMATS.merge!(
    :default =&gt; "%d %B %Y"
  )
  </code></pre>
  
  <p>Now it's displaying the right format when I use @show.date in the view, but the form helper is still displaying the raw format.</p>