Search code examples
formsruby-on-rails-4scaffolding

Rails 4 Select drop down not submitting values


I have a form partial that almost everything uses and the arrays for two fields that I am generating the drop downs from live in the model.

<div class="control-group">
      <%= f.label 'Quantity', :class => 'control-label' %>
      <div class="controls">
        <%= f.text_field :quantity, :class => 'form-control' %>
      </div>
      <%= error_span(@orders[:quantity]) %>
    </div>

This code works, the quantity class is usable and will update or populate on new order creation.

<div class="control-group">
  <%= f.label 'Model', :class => 'control-label' %>
  <div class="controls">
    <select name="model" class= 'form-control'>
      <%= Order::ORDER_MODELS.each do |model| %>
        <option value="<%= :model %>"><%= model %></option>
      <% end %>
    </select>
  </div>

This code does not work fine. I can see all the values in the selector list, but it fails to populate when creating an order or when updating existing orders that were pre-loaded via CSV.

I have one other field that is a number_field that also works. I have tried changing the value field from "<%= model %>" to the one it is at now, but I am not sure what is preventing this field from submitting.

how can I get the selector box to work with this form? I don't have any form gems installed. Is there some kind of f.select that I should be using instead of the way I am doing it?


Solution

  • SPACES. They get me every time. <%= f.select (:model, Order::ORDER_MODELS) %> wasn't working because of the space before the (