route of destruction
It’s a common thing that you have a nice javascript-driven link in your rails app to delete an object. Of course you could use a proper button_to but for some reason the boss wants a link. But the usual problem is that with a link_to as rails does it, you will rely completely on Javascript, not nice for old or crappy mobile browsers. The only problem that rails gives you is a missing routes for accessing the destroy action of a controller with a GET request. But, viola, here’s the plugin to solve this: route of destruction. For more see the README.
Oh, and don’t use the plugin.
February 20th, 2009 at 08:20 PM
Hm, that raised a few concerns for me. Are you sure that your boss didn’t want it to simply look like a link? It’s not too hard to style a button as a link. Secondly, in our projects we’ve been avoiding using “button_to” helper exactly because it’s tied up with javascript. The helper really just creates a form around your button on-the-fly (with js) and submits that form using js. Instead the form could be written by hand (with all the “_method” and “token” values in it), then button could just be restyled as a link, and you’re done.