Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 3最佳就地编辑嵌套模型_Ruby On Rails_Best In Place_Inplace Editing - Fatal编程技术网

Ruby on rails Rails 3最佳就地编辑嵌套模型

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

给定

但我不知道如何处理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 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