Creating a selection box

I want to display a selection box on a webpage using data from my DB.
The data is an array @schools returned by the find method of
ActiveRecord. I tried the following:

<% school = {:id => @student_data.school_id}%>
<%=collection_select :school, :id, @schools, :id, :name%>

I get the error:

undefined method `map’ for #School:0x8680ae4

Any ideas what my problem could be?

On 22 Aug 2008, at 00:51, Drew B. wrote:

I want to display a selection box on a webpage using data from my DB.
The data is an array @schools returned by the find method of
ActiveRecord. I tried the following:

<% school = {:id => @student_data.school_id}%>
<%=collection_select :school, :id, @schools, :id, :name%>

I get the error:

undefined method `map’ for #School:0x8680ae4

Sounds like @schools is a single record not an array.

Fred

You were right. I accidentally did a find_by instead of find_all_by.

Thanks!