Forum: Ruby on Rails question about RESTful resource routing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ball, Donald A Jr (Library) (Guest)
on 2007-08-01 01:24
(Received via mailing list)
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
This topic is locked and can not be replied to.