Restful ajax in droppables

How should i write a nice restful route for an ajax-call that adds a
tag to a particular game. I have games, they can have (multiple) tags,
and you can edit those in the admin_area, for which i have written
these resources:

map.namespace(:admin) do |admin|
admin.resources :games
admin.resources :tags, :member => {:add_to_game => :post}
end

which gives me admin_games_path etc. By the way, is that (the admin/
tags-controller) a good place for a method to add a tag to a game?
Should it be elsewhere (in the admin/game-controller for example)?

My problem is how i should write this in a drop_receiving_element tag,
especially how i can pass a put-method with it, since that seems more
logical in a restful-context. I had this in my routes (instead of
above)

map.namespace(:admin) do |admin|
admin.resources :games
admin.resources :tags, :member => {:add_to_game => :put}
end

but i didn’t know how to write that into my droppable-tag:

drop_receiving_element div_id, :url =>
add_to_game_admin_tag_path(someid), :hoverclass => ‘hover’

that one only seems to generate (ajax) post-requests, and i didn’t
succeed in passing a :method => :put with the url correcly.

How should i write that?

passing in a method in the options-hash seems to work now, didn’t get
that to work earlier.

what i’m still confused about is how to use my resource-paths in this
line

= drop_receiving_element :delete_bin, :url =>
admin_tag_path(needs_an_id_here), :method => :delete, :hoverclass =>
‘hover’

the admin_tag_path needs an id to be able to route to admin/
tags#destroy, is it even possible to use that (path)helper_method
here? (since i don’t have the id yet). adding a collection to the
resource that generates a route without an id to destroy a tag doesn’t
seem like the right way to go.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs