views:

53

answers:

1

I have a link_to like this:

<%= link_to 'X', category, :confirm => 'Are you sure?', :method => :delete %>

So, I change it like this:

<%=link_to_remote category.name,
            :confirm => 'Are you sure?', :method => :delete%>

it show the confirm box, but after I click "yes", it won't delete the item I want , why?

+3  A: 

There is no information about what url you need to go to in your link_to_remote usage. You should also specify something like

 :url => delete_category_path(category) 

in the options hash.

neutrino
because this method is calling on the /views/store, it is not calling the /views/categories, so, I have this error occur, how can I add the "delete_category_path"NoMethodError in Store#manageShowing app/views/store/manage.html.erb where line #13 raised:undefined method `delete_category_path' for #<ActionView::Base:0x103339308>
Ted Wong
The answer above assumes you have defined category as a resource in your config/routes.rb file. Doing that will add *_path and *_url helper methods, including the `delete_category_path`
Ben Marini
thanks Benalso you can always use the :url => { :action => "...", :controller => "..." } form
neutrino