title: Form select field options array in Rails. The rails way
body: <p>This is a simple question yet I'm having a hard time finding an answer. I have a select field in my form and I want to build the options array depending on my query records count. </p>
  
  <p>I'm getting my count like so in my controller:</p>
  
  <pre><code>@num_pages= Page.where(:site_id =&gt; @siteid).count
  </code></pre>
  
  <p>I want my options array to just be like {["1", 1], ["2", 2], ...} all the way up to @num_pages.</p>
  
  <p>Now <strong>I KNOW</strong> I can just do a loop and build that array but I want to know if there is a more <strong>"rails"</strong> way to do it. So that my select code could still be as simple as this:</p>
  
  <pre><code>&lt;%= select_tag(:nav_order, options_for_select(@num_pages)) %&gt;
  </code></pre>
  
  <p>...without using loops and array pushes and what have you.</p>
  
  <p>UPDATE</p>
  
  <p>Thanks to the responses my code now works like this. I decided to keep the mapping in the view instead of the controller however.</p>
  
  <pre><code>&lt;% options_array = (1..@page_count).to_a.collect{|p| ["#{p}", p]} %&gt;  
  &lt;%= select_tag(:nav_order, options_for_select(options_array)) %&gt;
  </code></pre>