This is genius!

October 24th, 2008 by Radar

I read Mike Gunderloy’s blog post today and afterwards thought he was crazy! I thought you couldn’t do Blog.find(“1-title”).

But you can.

If you pass in 1-title as params[:id] for any action and then pass it to find, find will do its “thing” and just execute find(1), giving you pretty URLs AND pretty code.

I later found out this was because find just calls to_i when it gets given strings, and calling it on “1-title” will give you “1″.

One Response to “This is genius!”

  1. Morris Bowers Says:

    tf053pjzpoamvj9o

Leave a Reply