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 << institution.id
     end
end
@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.
-Scott
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---