ruby on rails - How to create a sortable interface with 'acts as nested set' in RubyOnRails -


I am implementing some good interactive interfaces which can sort lists in my M Rail app, which is Uses the_act_as_list . I have a sort function that sets the status for each record after each record and drops the serial_alment script using the .aculo.us function.

This is an example of the controller action, which then sorts the drag and drop full:

  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 this together An example of the type of interface interaction that is a nested set ( acts_as_nested_set ):

How can I write a controller action to sort when the drag-and-drop ends?

I've added it: tree => seems to be sending the list of hashs in the correct _element function to the right parameter but it seems that I am still missing information about the whole nested order ....

I was sure it was done earlier and did not want to try to change the wheel again, but I can not find any examples of controller action.

Thank you

A good solution from a SQL-query

  # In your model: def self.order (id) update_all (['Ordinal = FIND_IN_SET (id,?)', Id.joined (',')], {: id = & gt; id}) end  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -