Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails: Date Picker not saving format
    primarykey
    data
    text
    <p>I have a form that creates a new entry into a database. One of the fields uses jquery Datepicker. At the moment, I can pick a date using the UI calendar and it displays in the right format in the textbox, but when I submit the form, the format changes back to the default setting, and saves in the database. I have had this working before on a older version of my site, and I tried following questions already posted, but had no luck. Hopefully someone can see the problem. Thanks.</p> <p>Here's part of my Project Controller:</p> <pre><code>def create @project = Project.new(params[:project]) @project.client = params[:new_client] unless params[:new_client].blank? @project.exception_pm = params[:new_exception_pm] unless params[:new_exception_pm].blank? @project.project_owner = params[:new_project_owner] unless params[:new_project_owner].blank? @project.role = params[:new_role] unless params[:new_role].blank? @project.industry = params[:new_industry] unless params[:new_industry].blank? @project.business_div = params[:new_business_div] unless params[:new_business_div].blank? respond_to do |format| if @project.save format.html { redirect_to @project, notice: 'Project was successfully created.' } format.json { render json: @project, status: :created, location: @project } else format.html { render action: "new" } format.json { render json: @project.errors, status: :unprocessable_entity } end end end </code></pre> <p>Here's part of my form view:</p> <pre><code>&lt;%= form_for(@project) do |f| %&gt; &lt;% if @project.errors.any? %&gt; &lt;div id="error_explanation"&gt; &lt;h2&gt;&lt;%= pluralize(@project.errors.count, "error") %&gt; prohibited this project from being saved:&lt;/h2&gt; &lt;ul&gt; &lt;% @project.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div class="field"&gt; &lt;%= f.label :start_date %&gt;&lt;br /&gt; &lt;%= f.text_field :start_date, :class =&gt; 'datepicker' %&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :end_date %&gt;&lt;br /&gt; &lt;%= f.text_field :end_date, :class =&gt; 'datepicker' %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>Here's my application.js file:</p> <pre><code>$(function() { $("#project_start_date").datepicker({dateFormat: 'dd-mm-yy'}); }); $(function() { $("#project_end_date").datepicker({dateFormat: 'dd-mm-yy'}); }); </code></pre> <p>Thanks in advance!</p>
    singulars
    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.
 

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