Ruby on rails Rails 3最佳就地编辑嵌套模型
给定 但我不知道如何处理incident.customer以获得customer.all的下拉列表(事件属于:customer)Ruby on rails Rails 3最佳就地编辑嵌套模型,ruby-on-rails,best-in-place,inplace-editing,Ruby On Rails,Best In Place,Inplace Editing,给定 但我不知道如何处理incident.customer以获得customer.all的下拉列表(事件属于:customer) 每次尝试时,我都会遇到各种错误。如果我正确理解您,在控制器的“显示动作”中,或在任何相关的地方: best_in_place incident, :notes, type: :input, nil: 'Add Note' 在你看来: @customer = Customer.all.map { |c| [c.id, c.customer_name] } # or
每次尝试时,我都会遇到各种错误。如果我正确理解您,在控制器的“显示动作”中,或在任何相关的地方:
best_in_place incident, :notes, type: :input, nil: 'Add Note'
在你看来:
@customer = Customer.all.map { |c| [c.id, c.customer_name] } # or whatever the customer name attribute is
这将生成所需的[[a,b],[c,d]]格式
对于Customer.pulk(:id,:name)来说,这就不那么冗长了,但在编写()时,这只是在Edge Rails中
@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