オプションを体系的に移動することで、これを打ち負かすことができると思いました。勝った。
index.html.erb と form.html.erb は現在のように機能します。
入札と連絡先の間に多対多の関係があり、そのテーブルのbid_idとcustomer_contact_idの間にbids_contactsがあります。
連絡先と入札モデルは次のとおりです。
has_and_belongs_to_many :bid_customer_contacts, :class_name => 'Bid',
:association_foreign_key => 'bid_id'
has_and_belongs_to_many :customer_contacts, :class_name => 'Contact', :foreign_key => 'customer_contact_id'
bids_controller.rbに特別なものはありません
show.html.erb ファイルで次のエラーが発生します。
Mysql2::Error: Unknown column 'bids_contacts.contact_id' in 'on clause':
SELECT `contacts`.* FROM `contacts` INNER JOIN `bids_contacts'
ON `contacts`.`id` = `bids_contacts`.`contact_id'
WHERE 'bids_contacts`.`customer_contact_id` = 15
コードは次のとおりです。
<b>Customer Contacts:</b>
<% if !@bid.customer_contacts.empty? %> <<===============
<ul>
<% @bid.contacts.each do |bc| %>
<li><%= link_to(bc.name, bc) %></li>
<% end %>
</ul>
<% else %>
No Customer Contacts<br/>
<% end %>
customer_contact_idではなく M2M テーブルでcontact_idを試しましたが、別のエラーが発生します。
この謎を解決するために何か他のことを共有する必要がある場合はお知らせください. ありがとう。