I'm having trouble with my verbs in Rails...
viewing a page for a resource (Dog) which has_many (Fleas). Embedded in dog's show.html.haml
is a call to render @dog.fleas
which automatically(?) finds & uses the template in "fleas/_flea.html.haml" to list each flea associated with said dog.
this displays correctly. whew! Now, next to each flea I've put a "Kill Flea" link that goes to a url: //localhost:3000/dogs/1/fleas/7
. Which is generated by:
= link_to("Kill Flea", [ flea.dog, flea ], :method => :delete, :confirm => "Sure? A bunny will die")
but every time that link is clicked there is no confirmation... and it renders the flea's show.html
page. it's as if it's using GET on /dogs/1/fleas/7
instead of DELETE?!?
ps- not worried about spiders & robots deleting things in my database... i'm just trying to learn Rails..and understand what's happening
Rails 3 uses unobtrusive javascript now. In Rails 2.3, erb would just shove all that messy javascript right into the link itself, in an onClick event. Now the javascript has been moved out of the link, and into external js files. Make sure you have this in your layout:
<%= javascript_include_tag :all %>
If you do have this, there might be deeper problems keeping your javascript from running, but this is the place to start. Let me know how it turns out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With