I''m having an issue using collection_select to create a drop down menu. All the guides say that this <%= collection_select(:page, :user_id, @users, :id, :full_name, :include_blank => false) %> should work but when I run the server, instead of a list of users appearing it''s just a blank list. The associations are that page belongs a user and a user has many pages, and there are users in the database that should be obtained in the controller when I call @users = User.all Any idea on how to get the drop down list to populate? This is the html code that is generated so something is missing/wrong but I''m not sure what it is. <select id="page_user_id" name="page[user_id]"> <option value="1"> </option> <option value="2"> </option> <option value="3"> </option> <option value="4" selected="selected"> </option> <option value="5"> </option> <option value="6"> </option> <option value="7"> </option> </select> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hassan Schroeder
2012-Sep-28 15:16 UTC
Re: collection_select doesn''t populate the drop down list
On Fri, Sep 28, 2012 at 7:49 AM, Ke En <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> <%= collection_select(:page, :user_id, @users, :id, :full_name, > :include_blank => false) %>> This is the html code that is generated> <select id="page_user_id" name="page[user_id]"> > <option value="1"> </option> > <option value="2"> </option> > <option value="3"> </option> > <option value="4" selected="selected"> </option> > <option value="5"> </option> > <option value="6"> </option> > <option value="7"> </option> > </select>Do those numbers look like valid user_id values? If so, are you sure your User model has a full_name method? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.