グループがシステムで使用できる複数のモジュールを選択できるようにするフォームを作成しようとしています。残念ながら、これを試すたびに、クレイジーな関連付けエラーが発生し続け、その理由がわかりません。
ここに私のフォームのコードがあります
<%= form_for @group, :url => admin_groups_path, :html => { :class => 'entry' } do |f| %>
<%= render :partial => 'shared/error_messages', :locals => { :object => @group } %>
<div class="g12">
<fieldset>
<fieldset>
<legend>Add Group</legend>
<div class="simple_format">
<section class="g3">
<%= f.label :name %>
<div><%= f.text_field :name, :size => 15 %></div>
</section>
<section class="g3">
<%= f.label :is_facility, 'Facility?' %>
<div style="display:block;margin: 0 auto;width:25px;"><%= f.check_box :is_facility %></div>
</section>
<section class="g3">
<%= f.label :parent_id %>
<div style="display:block;margin: 0 auto;width:25px;"><%= f.collection_select :parent_id, current_group.self_and_descendants.reject(&:is_facility), :id, :name %></div>
</section>
<section class="g3">
<%= f.label :time_zone, 'Time Zone' %>
<div><%= f.select :time_zone, ActiveSupport::TimeZone.all.map(&:name).select {|x| x=~ /US/} %></div>
</section>
</div>
<div class="simple_format">
<section class="g3">
<%= f.label :federal_tax_number, 'Federal Tax ID' %>
<div><%= f.text_field :federal_tax_number, :size => 15 %></div>
</section>
<section class="g3">
<%= f.label :national_provider_identifier, 'National Provider ID' %>
<div><%= f.text_field :national_provider_identifier, :size => 15 %></div>
</section>
<section class="g3">
<%= f.label :modules, 'Allowed Modules' %>
<div><%= f.collection_select :group_access_modules, AccessModule.all, :id, :name, {}, {:multiple => true} %></div>
</section>
</div>
<section class="g12">
<div><%= f.submit "Add Group", { :class => 'form-submit' } %></div>
</section>
</fieldset>
</fieldset>
</div>
<% end %>
これが私のモデルです
class Group < ActiveRecord::Base
has_many :group_access_modules
end
保存時に表示されるエラーは次のとおりです
<h1>
ActiveRecord::AssociationTypeMismatch
in Admin::GroupsController#create
</h1>
<pre>GroupAccessModule(#70245162706560) expected, got String(#70245155065480)</pre>
私は今、完全に迷っています。