Wednesday, November 5, 2008

Rails Dynamic Links

Since I've been working on a program for Mindbridge for a while, (and you can see how busy I am), I try occasionally to post useful things I remember here. One is about Rails dynamic linking abilities. I recently forgot, then remembered again, about how easy it is to link to an object.

(%= link_to "View", @object %) instead of (%= link_to "View", object_path(@object) %)

You can use a handy REST cheat sheet to keep it all handy. It helps me remember that I have to explicitly declare the delete method, for example, in my links.