Question about RESTful resource routing


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.


map.resources :nodes, :member=>{:order=>:put}


    <% @node.children.each do |child| %>
  • <%=h>
  • <% end %>
<%= sortable_element('list', :url=>order_node_url(@node)) %>


def order

reorder the nodes


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