Archive for the ‘Language’ Category

Dynamic is hot

Friday, May 12th, 2006

Oh one just has to adore the dynamic nature of Ruby coupled with the thoughtfulness of Rails.

I have a Feedtag object which has feed_id and tag_id members. Naturally with Rails you get to be able to find records using Feedtag.find_by_tag_id and Feedtag.find_by_feed_id. But what if you wanted to use both Ids to find a record?

No problem. Just use Feedtag.find_by_tag_id_and_feed_id. It is a bit of a mouthful but it works. No extra code, no SQL strings, just a bit of beautiful dynamic code.