Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a sortable interface with 'acts as nested set' in RubyOnRails
    primarykey
    data
    text
    <p>I've been implementing some nice interactive interfaces that can sort lists in my m rails app for models that use <code>acts_as_list</code>. I have a sort function that gets called and sets the position for each record afterr each drag and drop using the sortable_element script.aculo.us function.</p> <p>This is an example of the controller action that handles the sort after the drag and drop completes:</p> <pre><code> def sort params[:documents].each_with_index do |id, index| Document.update_all(['position=?', index+1], ['id=?', id]) end end </code></pre> <p>Now I am trying to do this same thing with a model that is a nested set (<code>acts_as_nested_set</code>). An example of the type of interface interaction: <a href="http://script.aculo.us/playground/test/functional/sortable_tree_test.html" rel="nofollow noreferrer">http://script.aculo.us/playground/test/functional/sortable_tree_test.html</a></p> <p>I am stuck on how to write the controller action to handle the sort when the drag and drop completes.</p> <p>I've added the :tree=>true parameter to the sortable _element function so far which appears to send a list of hashes but it seems that I am still missing information about the entire nested order....</p> <p>I was certain this has been done before and didn't want to try to reinvent the wheel, but I can't seem to find any examples of the controller action &lt;-> view with js function setup to handle a sortable <code>acts_as_nested_set</code></p> <p>Any help with creating an interactive sortable nested set in rubyonrails would be appreciated!</p> <p>Thanks,</p> <p>John</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.
 

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