How to create a select tag with dynamic options in Ruby on Rails?
<p>I am new in Ruby on Rails programming language. I want to show one dynamic dropdown. Here is my code:</p>

<p><strong>controller</strong></p>

<pre><code>def property
   @rental_types = RentalType.all
end
</code></pre>

<p><strong>views</strong></p>

<pre><code>&lt;%= form_tag(@property, method: "post", class: 'form-horizontal form-label-left', multipart: true, novalidate:"") do %&gt;
   &lt;%= select :property, :type_id, options_for_select(@rental_types.collect { |type|
                    [type.type_name.titleize, type.id] }, 1), {}, { id: 'countries_select', class: 'form-control col-md-7 col-xs-12' } %&gt;
&lt;% end %&gt;
</code></pre>

<p>My output should be</p>

<pre><code>&lt;select name="property[type_id]" class="form-control col-md-7 col-xs-12" id="countries_select"&gt;
   &lt;option value="10"&gt;1 Bedroom Rentals&lt;/option&gt;
   &lt;option value="11"&gt;2 Bedroom Rentals&lt;/option&gt;
   &lt;option value="12"&gt;3 Bedroom Rentals&lt;/option&gt;
   &lt;option value="13"&gt;4 Bedroom Rentals&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>I want to dynamic dropdown in my view page. But I am getting <code>undefined method 'type_id' for #&lt;User:0x7aff460&gt;</code> error message.</p>

<p>Please help me.</p>