1
내가 협회와 모델 공급 업체가 belongs_to :레일 4 열망 로딩 has_one 및
has_one :school, foreign_key: "school_vendor_id"
을 나는 협회와 모델 학교가이 :
@vendors = Vendor.includes(:school).where(:business_id=>@business.id)
:
belongs_to :vendor, foreign_key: "school_vendor_id"
나는 열망로드를 수행 한
보기에 문제가 있습니다. 내가 <%= v.school.inspect %>
할 경우
<% @vendors.each do |v| %><br/>
<%= v.vendor_name %><br/>
**<%= v.school.id %>** //Gives an error
undefined method `id' for nil:NilClass
, 나는 내가 학교 기록을 표시하는 방법을 알아낼 수 없습니다 다음과 같은 결과
#<School id: 1, school_vendor_id: 1.................
를 얻을.
감사합니다. 이 작동합니다. –