Ruby on Rails: Date Picker not saving format
===

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.

Here's part of my Project Controller:

    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

Here's part of my form view:


    <%= form_for(@project) do |f| %>
    
    
      <% if @project.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>
    
          <ul>
          <% @project.errors.full_messages.each do |msg| %>
            <li><%= msg %></li>
          <% end %>
          </ul>
        </div>
      <% end %>
    

       <div class="field">
        <%= f.label :start_date %><br />
        <%= f.text_field :start_date, :class => 'datepicker' %>
      </div>
    
    <div class="field">
        <%= f.label :end_date %><br />
        <%= f.text_field :end_date, :class => 'datepicker' %>
      </div>
    
      
     
      <div class="actions">
        <%= f.submit %>
      </div>
    <% end %>

Here's my full layout/application view:

    <!DOCTYPE html>
    <html>
    <head>
      <title>ExceptionApp</title>
      <%= stylesheet_link_tag    "application", :media => "all" %>
      
      <%= csrf_meta_tags %>
    </head>
    <body>
    
    
    
    <%= yield %>
    
    
    
    <!-- Javascripts
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <%= javascript_include_tag "application" %>
    
    <head>
      <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
      
      
    </head>
        
        <script type="text/javascript">
          jQuery(function() {
            return $('.datepicker').datepicker({
              dateFormat: "<%= I18n.t('datepicker.date.formats') %>",
              dayNames: <%= I18n.t('datepicker.day.names.full') %>,
              dayNamesMin: <%= I18n.t('datepicker.day.names.short') %>,
              monthNames: <%= I18n.t('datepicker.month.names.short') %>,
              monthNamesShort: <%= I18n.t('datepicker.month.names.short') %>
            });
          });
        </script>
    
    </body>
    </html>

Here's my application.js file:

    $(function() {
      $("#project_start_date").datepicker({dateFormat: 'dd-mm-yy'});
    });
    
    $(function() {
      $("#project_end_date").datepicker({dateFormat: 'dd-mm-yy'});
    });

and here's my main.js.coffee file:

    jQuery ->
      $('.datepicker').datepicker({ dateFormat: "dd/mm/yy" })


Thanks in advance!