Q:

Select boxes in form

Ask this question I have searched and read the form_helpers guide.
I'm create a controller like a job board.
In form the user can choose how much he would pay and by what (hour, day, contract).
So my form look like this
# _form.html.erb

  <div class="field">
    <%= f.label :pay, "Pay" %><br>
    <%= f.number_field :pay, required: true %>
  </div>

And show
# show.html.erb

<%= @thecontroller.pay %> / xxx

Instead of "/ xxx" I want show the user choice.
In form, I want a list with 3 entry "Hour", "Day" and "contract"
I tested with something like that but I don't understant
  <select name="city_id" id="city_id">
    <option value="1">Lisbon</option>
    <option value="2">Madrid</option>
    <option value="12">Berlin</option>
  </select>

I need to create an another column ?
I need to create a helper or other code besides form ?
Thank you for you time.

A:

Use the select method.  The second argument is an array of arrays, the elements being first the value to display, and second the value to return.
<%= f.select :pay, [['Hour', 1], ['Day' , 2], ['Contract', 3]], required: true %>

Create a helper method for the show page..
class ApplicationController < ActionController::Base

  helper_method :show_pay

  def show_pay(n)
    %w(x Hour Day Contract)[n]
  end
end

And in your view you can do...
<%= show_pay(@thecontroller.pay) %> / xxx

