[英]Rails 3 best_in_place Edit Nested Model
給定
<% @incidents.each_with_index do |incident,i| %>
我不知道如何在事件和父級關聯(例如identity.user或incident.contact)上放置編輯屬性
例如,這適用於:
best_in_place incident, :notes, type: :input, nil: 'Add Note'
但是我不知道怎么做event.customer來獲取Customer.all的下拉列表(identification Emirates_to:customer)
我嘗試每種方式都會遇到各種錯誤。
如果我理解正確,在控制器的顯示操作中或相關的地方,則:
@customer = Customer.all.map { |c| [c.id, c.customer_name] } # or whatever the customer name attribute is
您認為:
= best_in_place incident, :notes, :type => :select, :collection => @customer
這將產生文檔說需要的[[a,b],[c,d]]格式。
使用Customer.pluck(:id,:name)不會那么費力,但這僅在撰寫本文時在Edge Rails中使用( 鏈接到guides )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.