Q:

select field in rails

How I can to pass an array like generated by a controler with the following code:
tipos= Type.all
    @listadotipos=[]
    tipos.each do |h|
            @listadotipos.push(h.name)
    end

The last code generate an array called @listadotipos. This array is passed to a html.erb view and I want to show all array components inside a Select field in the view.
The select field works this:
   <%= f.select :make, options_for_select(["option1", "option2"]) %>

How I can do this. Please help me.

A:

First of all your controller code can be cleaned up like so:
@listadotipos = Type.all.map(&:name)

Your view code should work if you use the variable instead of your hard coded array:
<%= f.select :make, options_for_select(@listadotipos) %>

