have some custom attr_accessor in my model.
When I try to create a new model using the params[:model] I’m getting this error:
ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: entity_select, office_select):
class Expedient < ActiveRecord::Base
belongs_to :enterprise
has_many :document
attr_accessor :entity_select
attr_accessor :office_select
...
I suppose Rails know that those are att_accessor and should not be saved on the model in the database.
Or not ?
I’m using this attr_accessor for creating some help field using simple_form:
<%= f.input :entity_select,:label => 'Entity', :input_html => {:class => "span2"}, :wrapper => :prepend do %>
<span class="add-on"><i class="icon-search"></i></span><%= f.input_field :entity_select, :class => "span2 typeahead_entity", :id_selected => '99', :id => 'typeahead_centre'%>
<%end%>
I need a special text input for a typeahed, but I want to create this input using simple_form, like other ‘real’ fields, that’s why I’m using a ‘not real attribute’…
thanks,
EDIT:
The error is not when saving, just before, when assigning the params to the model attributes here:
@expedient=Expedient.new.attributes=params[:expedient]
Make the
entity_selectandoffice_selectattributes accessible: