With all the hard work going about, I only just recently noticed this cute litte helper. A helper function named ‘dom_id’ will turn any ActiveRecord model into a handy string that everyone uses to identify DOM ids.
Here’s an example that PHP-ers will surely recognize.
<div id="bookmark_<?=$bookmark->id?>">
This technique is used all the time to identify multiple records on one html page. It turns out that Rails 2 has Simply Helpful’s cute little helpers on board! So instead of that thing above, you just write this:
<div id="<%=dom_id(bookmark)%>">
Ahhh. Much better.

Subscribe to our RSS feed


0 Responses to “Such a cute little helper”