title: jQuery-UI Sortable Connected-Lists save order and association to rails model
body: <p>Let's say that I have:
  a 'Survey' with many 'Questions' which has many 'Answers'</p>
  
  <p>If I had a 'Survey' that had 2 instances of a 'Question', let's call them: 'Good Question' and 'Bad Question'</p>
  
  <p>'Good Question' has 5 'Answers' and 'Bad Question' has 3 'Answers'</p>
  
  <p>If 'Good Question' and 'Bad Question' were connected sortable lists with this jQuery-UI interaction. <a href="http://jqueryui.com/sortable/#connect-lists" rel="nofollow noreferrer">http://jqueryui.com/sortable/#connect-lists</a></p>
  
  <p>I know how to display them as 2 sortable lists using the jQuery-UI and I can also drop an 'Answer' from a 'Bad Question' to a 'Good Question'. But how would I save their new sorted positions and their newly sorted association to another 'Question' back to a Rails database?</p>
  
  <p>Railscasts has how to save position for a single sortable lists but not for lists that belong to different associated models.
  <a href="http://railscasts.com/episodes/147-sortable-lists-revised" rel="nofollow noreferrer">http://railscasts.com/episodes/147-sortable-lists-revised</a></p>
  
  <p>I really appreciate the help here!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I realized that I just need to POST to the Rails controller, an element id of the list that I dropped the 'Answer' into (i.e <code>&lt;ol class = "connectableSortable" id = "Good_Question"&lt;/ol&gt;</code>) </p>
  
  <p>This is the syntax for how the Railscast does a POST to the Rails Controller to pass an array of object_id's in the sortable order.</p>
  
  <pre><code>jQuery -&gt;
    $('#faqs').sortable(
      axis: 'y'
      update: -&gt;
        $.post($(this).data('update-url'), $(this).sortable('serialize'))
    )
  </code></pre>
  
  <p>How would I update this POST to pass the list ID to it, so I can just update the 'Question' foreign key for the 'Answer' to the list 'ID' that it fell into?</p>
  
  <p>This SO answer has a way to retrieve the list ID. <a href="https://stackoverflow.com/questions/9584816/jquery-sortable-get-the-item-object-where-the-element-is-dropped">Get the item/object where the element is dropped</a></p>
  
  <p>So now, I really just need to know how to pass an extra parameter back to the rails controller. Any help?</p>