Sit back, relax, and enjoy the code.

Better Rails Searching with Named Scopes using Scope Builder

Posted: December 22nd, 2008 | Author: gabe | Filed under: Rails | Tags: , , | No Comments »

When it comes writing elegant search code in a Rails app, Named Scopes immediately come to mind.  And for good reason: they’re a fantastic way to express, well, scopes, for your searches.  In your Person model, you might have named scopes like by_last_name, by_age, and by_sex.  But, what do you do when you want to give your users a search form and let them find people by any combination of last name, age, and sex?

Read the rest of this entry »

  • Share/Bookmark