Skip to content

Instantly share code, notes, and snippets.

@adamgamble
Created November 6, 2010 06:18
Show Gist options
  • Save adamgamble/665232 to your computer and use it in GitHub Desktop.
Save adamgamble/665232 to your computer and use it in GitHub Desktop.
def search
bucket = Person
#Narrow our query depending on params sent
bucket = bucket.hair_color(params["hair_color"]) unless params["hair_color"].blank?
bucket = bucket.enjoys_chunky_bacon(params["chunky_bacon_preference"]) unless params["chunky_bacon_preference"].blank?
bucket = bucket.age_between(params["age_lower_limit"], params["age_upper_limit"]) unless params["age_lower_limit"].blank? && params["age_upper_limit"].blank?
#This actually does the query, if no params were sent then all people will be returned.
@people = bucket.all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment