title: How to populate a dropdown in rails using a loop?
body: <p>I would like to populate a dropdown in Rails dynamically using a loop. I want to display the number of days 1 to 30 in the dropdown. I tried this but it printed the <code>select</code> box multiple times on my html page. </p>
  
  <pre><code>  &lt;%
      for i in 0..30
    %&gt;
        &lt;%= select_tag "time_id", options_for_select([['Last #{i} days', i]]), class: 'form-control' %&gt;
    &lt;%
      end
    %&gt;
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Last #{i} days got displayed 30 times within individual select boxes.
  </code></pre>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>&lt;select&gt;
      &lt;option name='1'&gt;Last 1 day&lt;/option&gt;
      &lt;option name='2'&gt;Last 2 days&lt;/option&gt;
      &lt;option name='3'&gt;Last 3 days&lt;/option&gt;
      ...
      ...
      &lt;option name='30'&gt;Last 30 days&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>