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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 22 Aug 2008, at 00:51, Drew Batshaw 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> Any ideas what my problem could be? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You were right. I accidentally did a find_by instead of find_all_by. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---