我有一个简单的表单,允许您选择用户和医院。表单已成功提交。然而,当我查看index.html.erb时,它看起来如下所示: imgur。你知道为什么“全名”和“医院”没有出现吗?
<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 %>发布于 2013-01-14 07:02:38
这不就像是
<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>否则会破坏表单帮助器。
如有疑问,请查看这里的接口:collection_select
https://stackoverflow.com/questions/14309145
复制相似问题