Re: options_from_collection_for_select

Colin Law
Fri, 18 Jan 2013 13:46:12 -0000

On 18 January 2013 12:19, Gerry Brown
<gerbreown1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I have just started using RoR and am creating some select boxes on my form
> with the following code:
> <%= select_tag(options_from_collection_for_select(Owner.all, :id,
:fname))
> %>
> My problem is that it does NOT return the first record from the table, but
> just the second and succeeding records.

Check the docs for select_tag and you will see that you are missing
the first parameter.  Perhaps you meant to use f.select, which is
generally the right way to do it.

For the future have a look at the Rails Guide on debugging which will
show you techniques that you can use to debug your code.

Colin