title: Double Saving after AJAX-Call
body: <p>i have a weird problem by saving a record with AJAX and Rails. I want to save a record by using drag'n drop with jQuery Sortable (<a href="http://jqueryui.com/sortable/#connect-lists" rel="nofollow">http://jqueryui.com/sortable/#connect-lists</a>). The saving is working fine... nearly. the same record, which should be saved by dragging an element from one list to another, is saved twice :( i have no idea why. maybe someone can help me...  </p>
  
  <p><strong>view/dev_languages/new.html.haml</strong></p>
  
  <pre><code>=title_header(t('.your_qualifications'))
  #dev_languages
    .container_12
      #dev_language_type_btns
        %span#application_btn= 'Application'
        %span#web_btn= 'Web'
        %span#mobile_btn= 'Mobile'
  
    .container_12
      .grid_6
        #application_dev_languages
          =render @application_dev_languages
        #web_dev_languages
          =render @web_dev_languages
        #mobile_dev_languages
          =render @mobile_dev_languages
      .grid_6
        %h3= "Skill Wall"
        %ul#skill_wall.connectedSortable
          %li= "blubb"
          %li= "bla"
  </code></pre>
  
  <p><strong>assets/javascripts/dev_languages.js.coffee</strong>  </p>
  
  <pre><code>$("#languages, #skill_wall").sortable(
    connectWith: ".connectedSortable"
    update: -&gt;
      alert "www"
      $.ajax
        url: "/has_dev_languages"
        type: "post"
        #processData: false
        data:
          creator_id: 1
          creator_type: "Expert"
          application_type_id: 1
          dev_language_id: 1
    ).disableSelection()
  </code></pre>
  
  <p><strong>controllers/has_dev_languages_controller.rb</strong>  </p>
  
  <pre><code>class HasDevLanguagesController &lt; ApplicationController
    before_filter :authenticate_user!
  
    def create
      @has_dev_languages = HasDevLanguage.create(
          :creator_id       =&gt; params[:creator_id],
          :creator_type     =&gt; params[:creator_type],
          :application_type_id =&gt; params[:application_type_id],
          :dev_language_id  =&gt; params[:dev_language_id]
      )
      respond_to do |wants|
        wants.js
      end
    end
  </code></pre>
  
  <p>end</p>
  
  <p><strong>controllers/dev_languages_controller.rb</strong></p>
  
  <pre><code>class DevLanguagesController &lt; ApplicationController
    before_filter :authenticate_user!
    before_filter :find_base_data
  
    private
  
      def find_base_data
        @application_dev_languages  = DevLanguage.where(:application_type_id =&gt; '1')
        @web_dev_languages          = DevLanguage.where(:application_type_id =&gt; '2')
        @mobile_dev_languages       = DevLanguage.where(:application_type_id =&gt; '3')
      end
  </code></pre>
  
  <p>end</p>
  
  <p><strong>view/has_dev_languages/create.js.erb</strong></p>
  
  <pre><code>window.location.reload();
  </code></pre>
  
  <p><strong>Server-Log</strong></p>
  
  <pre><code>Started POST "/has_dev_languages" for 127.0.0.1 at 2013-08-03 12:18:27 +0200
  Processing by HasDevLanguagesController#create as */*
    Parameters: {"creator_id"=&gt;"1", "creator_type"=&gt;"Expert", "application_type_id"=&gt;"1", "dev_language_id"=&gt;"1"}
    User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
     (0.1ms)  BEGIN
    SQL (0.2ms)  INSERT INTO `has_dev_languages` (`application_type_id`, `created_at`, `creator_id`, `creator_type`, `dev_language_id`, `job_posting_id`, `updated_at`) VALUES (1, '2013-08-03 10:18:27', 1, 'Expert', 1, NULL, '2013-08-03 10:18:27')
     (1.3ms)  COMMIT
    Rendered has_dev_languages/create.js.erb (0.0ms)
  Completed 200 OK in 10ms (Views: 4.6ms | ActiveRecord: 2.0ms)
  
  
  Started POST "/has_dev_languages" for 127.0.0.1 at 2013-08-03 12:18:27 +0200
  Processing by HasDevLanguagesController#create as */*
    Parameters: {"creator_id"=&gt;"1", "creator_type"=&gt;"Expert", "application_type_id"=&gt;"1", "dev_language_id"=&gt;"1"}
    User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
     (0.1ms)  BEGIN
    SQL (0.2ms)  INSERT INTO `has_dev_languages` (`application_type_id`, `created_at`, `creator_id`, `creator_type`, `dev_language_id`, `job_posting_id`, `updated_at`) VALUES (1, '2013-08-03 10:18:27', 1, 'Expert', 1, NULL, '2013-08-03 10:18:27')
     (1.6ms)  COMMIT
    Rendered has_dev_languages/create.js.erb (0.0ms)
  Completed 200 OK in 10ms (Views: 4.5ms | ActiveRecord: 2.3ms)
  
  
  Started GET "/has_dev_languages/__meta_request/d7377832adbf2d9a0460a0a4426b5d2f.json" for 127.0.0.1 at 2013-08-03 12:18:28 +0200
  
  
  Started GET "/de/dev_languages/new" for 127.0.0.1 at 2013-08-03 12:18:29 +0200
  Processing by DevLanguagesController#new as HTML
    Parameters: {"locale"=&gt;"de"}
    User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
    DevLanguage Load (0.3ms)  SELECT `dev_languages`.* FROM `dev_languages` WHERE `dev_languages`.`application_type_id` = 1
    Rendered dev_languages/_dev_language.html.haml (0.1ms)
    DevLanguage Load (0.2ms)  SELECT `dev_languages`.* FROM `dev_languages` WHERE `dev_languages`.`application_type_id` = 2
    Rendered dev_languages/_dev_language.html.haml (0.1ms)
    DevLanguage Load (0.1ms)  SELECT `dev_languages`.* FROM `dev_languages` WHERE `dev_languages`.`application_type_id` = 3
    Rendered dev_languages/_dev_language.html.haml (0.1ms)
    Rendered dev_languages/new.html.haml within layouts/application (6.3ms)
    Rendered shared/_flashes.html.haml (0.1ms)
    Rendered shared/_header.html.haml (1.1ms)
    Rendered shared/_footer.html.haml (0.4ms)
    Rendered devise/shared/_links.erb (0.6ms)
    Rendered modals/forms/_login_expert_form.html.haml (12.0ms)
    Rendered modals/_login_expert.html.haml (12.8ms)
  Completed 200 OK in 205ms (Views: 202.5ms | ActiveRecord: 1.0ms)
  
  
  Started GET "/has_dev_languages/__meta_request/a9d0157927d47455f5af2be3593404c5.json" for 127.0.0.1 at 2013-08-03 12:18:29 +0200
  
  
  Started GET "/de/dev_languages/new/__meta_request/fa0990fcfbf1ee313d620ed95e7aa3d4.json" for 127.0.0.1 at 2013-08-03 12:18:29 +0200
  </code></pre>
  
  <p>Please help me. I'm sitting here for 3 days with this problem! :( :( :(</p>
  
  <p>Thanks!</p>