Topic: Problem with Can't mass-assign protected attributes: driver_ids

Getting this error when trying to use a many join model.  I know this is a simple solution.  Would someone please tell me smilehttp://www.github.com/brockf12/vi.git or http://www.github.com/brockf12/vi/

<%= form_for(@trip) do |f| %>
  <% if @trip.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@trip.errors.count, "error") %> prohibited this trip from being saved:</h2>

      <ul>
      <% @trip.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :trip %><br />
    <%= f.text_field :trip %>
  </div>


<div class="field">
   <%= f.label :driver_ids %><br />
  <%= f.text_field :driver_ids %>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

Last edited by veex (2012-07-20 03:00:50)

Re: Problem with Can't mass-assign protected attributes: driver_ids

Put in your model:

attr_accessible :driver_ids

Re: Problem with Can't mass-assign protected attributes: driver_ids

I put the attr_accessible :driver_ids in the trip model. 

Now I'm getting could not find driver_id = 0.  How do I order that by name?  I guess this is a good opportunity for a drop down or a checkbox.  But the form should enter a new driver's name in the textbox. 

Any solutions?