Hi guys. I've got a tree of Nodes which I'd like to edit via a RESTful controller. The wrinkle at the moment is enabling manual ordering of the nodes - that is to say, given a node, I want the user to be able to reorder its children.
routes.rb:
map.resources :nodes, :member=>{:order=>:put}
edit.rhtml:
<ul id="list"> <% @node.children.each do |child| %> <li id="child_<%=child.id%>"><%=h child.name%></li> <% end %> </ul> <%= sortable_element('list', :url=>order_node_url(@node)) %>
nodes_controller.rb:
def order # reorder the nodes end
Unfortunately, dragging nodes in the list issues a POST request, which rails rightfully rejects as improper for the order_node_url. I could fix this by changing routes.rb to map :order to :post, but I believe that's improper semantics.
What should I do in order to correct this? I would have thought the order_node_url helper would automatically generate a PUT request.
- donald