モデルリソースがあります。割り当てとの関連付けがあります。私は Simple_form_for gem を使用しています。リソース名とその役割を表示して、myu resource_vteam_allocation フォームで一意に識別できるようにします。リソースがタイトル値を使用することを期待して、リソースにタイトルメソッドを既に定義しましたが、無駄です。<%= f.association :resource, :required=>:true,:collection=>@selected_resource %>
resource_type に関連付けられたリソース値を表示するには、このステートメントでどのような変更が必要か教えてください
class Resource < ActiveRecord::Base
belongs_to :resource_type
has_many :resource_vteam_allocation, :dependent => :destroy
has_many :vteams, :through => :resource_vteam_allocation
accepts_nested_attributes_for :resource_vteam_allocation, :allow_destroy => true
def title
"#{name} #{resource_type.title}"
end
end
class ResourceVteamAllocation < ActiveRecord::Baseの所属先:resource
終わり
<%= simple_form_for([@resource_vteam_allocation.vteam, @resource_vteam_allocation],:remote=>true, :html=>{:multipart=>true}) do |f| %>
<%= f.error_notification %>
<div class="inputs">
<%= f.association :resource, :required=>:true,:collection=>@selected_resource %>
<%= f.input :resource_type, :required=>:true, :label=>"Joining As" %>
<%= f.association :resource_billing_type, :required=>:true, :label=>"Billing Type" %>
</div>
<div class="actions" >
<%= f.button :submit, :class=>'button big' %> <span style="vertical-align: bottom">or</span> <%= link_to "Cancel", "#", :id=>'new-xdoc-cancel' %>
<% end %>
</div>