Help with query and testing array

I am working on an app with a Flex front end and part of that is to search for an
institution by name.

I have it working if the user enters the school name exactly, but I need to deal with
multiple results being returned, specifically how to test if multiple results were
returned, if they are to change the SQL statement.

Code with notes below:

@query = params[:iname][:id] <-- an xml result from Flex
@new_query = "%" +@query+ "%"

@institutions = Institution.find(:all, :conditions => ["institution_name like ?", @new_query])

if @institutions.length > 1
   @inst_query = "institution_id in"
     for institution in @institutions
       @inst_id <<

@events = Event.find(:all, :conditions => ["(institution_id = ?)", @institutions], :order => "event_start_date")

Note - the code is not working as above. I will need to change the query to be (institution_id IN (x,x,x)).

When I test for length I get an error about nil object.

Thanks in advance for your help.