views:

59

answers:

2

Hi all,

I'm trying to create a user managment system where users can be dragged and dropped along different groups (copy and move users). I use

drop_receiving_element "move_drop_zone_1", 
  :update => "users", 
  :url => move_user_path(:target_node_id => node.id),
  :method => :put,
  :accept => "move_user", 
  :hoverclass => "node-active"

to define a dropzone.

I have a problem with the path. Above code results in

move_user_url failed to generate from {:action=>"move", :controller=>"users", :target_node_id=>2}, expected: {:action=>"move", :controller=>"users"}, diff: {:target_node_id=>2}

In my routes i defined map.resources :users, :member => { :move => :put, :copy => :put }

Apparently Rails is not expecting the target_node_id but how can I include this?

thanks Stijn

+2  A: 

Hi Stijn,

The move_user_path is a "member" path. Therefore, you will also need to provide the :id for the user member you are referring to.

So you might have:

move_user_path(:id => current_user.id, :target_node_id => node.id)

Or, you will need to change your routes to:

map.resources :users, :collection => { :move => :put, :copy => :put }

And then your path becomes:

move_users_path(:target_node_id => node.id)

Hope this helps.

Joerg

Joerg
Thanks for the reply. Still some problems...When I do <%= link_to "move user", move_users_path(:target_node_id => 1), :method => :put %> the update method of the users controller gets called and not the move. <%= link_to "move user", move_users_path(:target_node_id => 1) %> the show method of the users controller gets called and not the move. I defined map.resources :users, :collection => { :move => :put, :copy => :put } in routes
Tarscher
+1  A: 

Joerg is right.

Also, a very good resource to learn more about routing is on Ruby On Rails guides

Silviu Postavaru