Array of Objects

I have a collection of objects of differing types, and I want to grab all of one type of object into another collection. Would this be roughly the correct way to do it:

surveys = Survey.find(:all) some_survey_types = surveys.collect{|survey| survey.type == “Some_Survey_Type”}

I am admittedly a Rails newbie, but wouldn't the following code work: some_survey_types = Survey.find_by_type("Some_Survey_Type")

Hi, thanks for the response. Yes, that works, but I already have the collection in memory, and don’t want to hit the database needlessly with another find. In my example I used the find just to generally show what the collection is, and as a result over simplified it!

No, you'll end up with an array of boolean values.

Try

some_survey_types = surveys.select {|survey| survey.type == "Some_Survey_Type"}

Thanks a ton, I was a hair off.