# Drag&Drop w/ Rest

**URL:** <https://www.ruby-forum.com/t/drag-drop-w-rest/109390>\
**Category:** Rails\
**Created:** [July 14, 2007, 2:15am UTC](https://www.ruby-forum.com/t/drag-drop-w-rest/109390 "2007-07-14T02:15:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cloper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f07891/32.png) [@cloper](https://www.ruby-forum.com/u/cloper)\
**Post date:** [July 14, 2007, 2:15am UTC](https://www.ruby-forum.com/t/drag-drop-w-rest/109390/1 "2007-07-14T02:15:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cloper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f07891/32.png) [@cloper](https://www.ruby-forum.com/u/cloper)\
**Post date:** [July 14, 2007, 10:54am UTC](https://www.ruby-forum.com/t/drag-drop-w-rest/109390/2 "2007-07-14T10:54:37Z")

</div>

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](http://www.nedforce.nl)
