1
사용자를 선택하고 병원을 선택할 수있는 간단한 양식이 있습니다. 양식이 성공적으로 제출됩니다. 그러나 index.html.erb를 보면 다음과 같이 보입니다 : [imgur] [1]. "성명"과 "병원"이 나타나지 않는 이유는 무엇입니까? 그데이터가 테이블에 나타나지 않습니다.
<div class="field">
<%= f.collection_select :hospital_id, Hospital.all, :id, :name %>
</div>
및
<div class="field">
<%= f.collection_select :user_id, User.all, :id, :full_name %>
</div>
처럼
<div class="field">
<%= f.label :booking_reference %>
<br/>
<%= f.text_field :booking_reference %>
</div>
<div class="field">
<%= fields_for :User do |user| %>
<%= user.collection_select :user_id, User.all, :id, :full_name %>
<% end %>
</div>
<div class="field">
<%= fields_for :hospital do |hosp| %>
<%= hosp.collection_select :hospital_id, Hospital.all, :id, :name %>
<% end %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
:
의심에서, 여기에 API를 확인합니다. 그런 식으로하면 다음과 같은 오류가 발생합니다 #에 대해'Hospital_bookings # 새 정의되지 않은 메서드 user_id에서 NoMethodError ' –
HospitalBookings 모델에 user_id 속성이 있습니까? –
내 질문을 업데이트하고 HospitalBooking 모델을 추가했는데 –