Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think, Rails/Ruby is not able to parse a date in this format:</p> <pre class="lang-js prettyprint-override"><code>$("#question_deadline").datepicker("option", "dateFormat", "DD, d MM, yy"); // full day name, day (w/o leading zero), full month name, 4-digit year </code></pre> <p>In your controller, you might want to add a line such as</p> <pre class="lang-ruby prettyprint-override"><code>def create/update ... @question.deadline = DateTime.strptime(params[:question][:deadline], '%A, %d %B, %Y') # assuming my jquery-to-ruby format-mapping is adequate ;-) if @question.save ... end </code></pre> <p>Beware, that this code easily breaks on malformed date strings.</p> <p>If you don't want to change the format to, e.g. <code>'yy-mm-dd'</code> (in Ruby-land it's <code>'%Y-%m-%d'</code>), you may want to populate the selected date to another HTML element using the <a href="http://jqueryui.com/demos/datepicker/#option-altFormat" rel="nofollow"><code>altField</code> option</a> and hide the actual datepicker input field via CSS:</p> <pre class="lang-js prettyprint-override"><code>$("#somewhere_else").datepicker( dateFormat: "%yy-%mm-%dd", altField: "#question_deadline", altFormat: "DD, d MM, yy", ... ); </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;%= form_for @question do |f| %&gt; ... &lt;%= text_field_tag 'somewhere_else', @question.deadline %&gt; &lt;%= f.hidden_field :deadline %&gt; ... &lt;% end %&gt; </code></pre> <p>That'll work, at least for me :-)</p> <p>—Dominik</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload