Drag&Drop w/ Rest

So I have run into a problem:

I have a restful setup where a user clicks on an item to view it.
once viewing the item, they can drag&drop characteristics onto the item.

map.resources :items, :member => { :apply => :post }

in the drop_receiving_element I have:

url => apply_item_path(@item)

The problem is when you drag&drop, it does post to the action, but
the passed parameters are :id, which is @item.id, characteristic.id
is nowhere to be found. I’m assuming there is an issue with the
routes not passing the additional parameter.

Any help would be appreciated

cloper wrote:

The problem is when you drag&drop, it does post to the action, but
the passed parameters are :id, which is @item.id, characteristic.id
is nowhere to be found. I’m assuming there is an issue with the
routes not passing the additional parameter.

You are right – because the route isn’t nested, the URL and path
helpers have no knowledge about passing on other variables. This is not
to say that I recommend nesting the resource, because that wouldn’t seem
to reflect reality.

What you can always do is post additional variables by using the
old-school { :controller, :action, :var1, :var2, :varx } hash (which in
no violates RESTfulness) or simply name the drag & drop element as
“characteristic_id” and do a quick @characteristic =
Characteristic.new(params[:characteristic_id]) in your controller.


Roderick van Domburg
Nedforce http://www.nedforce.nl