I have implemented some nice interactive interfaces that can sort lists in my m rails application for models that use acts_as_list . I have a sort function that is called and sets the position for each record after each drag using the sortable_element script.aculo.us function.
This is an example of a controller action that handles sorting after the drag and drop is completed:
def sort params[:documents].each_with_index do |id, index| Document.update_all(['position=?', index+1], ['id=?', id]) end end
Now I'm trying to do the same with the model, which is a nested set ( acts_as_nested_set ). An example of an interface interaction type: http://script.aculo.us/playground/test/functional/sortable_tree_test.html
I was fixated on how to write a controller action to handle sorting when dragging is completed.
I added a parameter: tree => true for the sortable _element function so far, which seems to send a list of hashes, but it seems like I still lack information about the entire nested order ....
I was sure that this was done earlier and did not want to try to reinvent the wheel, but I can not find any examples of the β view controller action with js function setting to handle sortable acts_as_nested_set
Any help on creating an interactive sortable nested set in rubyonrails would be appreciated!
Thanks,
John
ruby ruby-on-rails nested-sets scriptaculous
Streamline
source share