GabesStudio
The rewards.

The rewards.

Mmmmmm, pork butt for dinner. 
Second meal from the new grill.

Mmmmmm, pork butt for dinner.
Second meal from the new grill.

Searching Multiple Attributes in Simple Search

Based on this Railscast there seemed to be several questions in the comments section about how to search more than one parameter at a time.

The answer is to set up your search query the same way you would chain where conditions in a scope. The simple answer would look like this:

def self.search(search)
 if search
  find(:all, :conditions => ['first_name LIKE ? || last_name LIKE ? || company_name LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%"])
 else
  find(:all)
 end
end
By Jonathan Mak Long

By Jonathan Mak Long

Awesome Flags

My first gem is here!

It’s called awesome_flags, and you can get it here.

Bundler users just:

gem 'awesome_flags'

If you use FlagShihTzu to flag models, then this gem will save you some hassle and repetition when using those flags in forms as well as just being a handy way to list out the flag names assigned to objects.

You’ll need the FlagShihTzu plugin to use it. Full details in the docs with examples for use.