그룹이 시스템에서 사용할 수있는 여러 모듈을 선택할 수있는 양식을 만들려고합니다. 불행히도 이것을 시도 할 때마다 미친 연관 오류가 계속 발생하고 이유가 없습니다. 여기 has_many 관계 루비를 사용하여 폼 만들기
내 양식을 여기<%= 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 %>
의 코드 것은 내가 완전히 지금 분실하고 내가
<h1>
ActiveRecord::AssociationTypeMismatch
in Admin::GroupsController#create
</h1>
<pre>GroupAccessModule(#70245162706560) expected, got String(#70245155065480)</pre>
저장에 얻을 오류 내 모델 여기
class Group < ActiveRecord::Base
has_many :group_access_modules
end
입니다 .
GroupsController 코드도 게시하십시오. – vee