Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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 为嵌套模型创建表单_Ruby On Rails - Fatal编程技术网

Ruby on rails 为嵌套模型创建表单

Ruby on rails 为嵌套模型创建表单,ruby-on-rails,Ruby On Rails,我在拍卖应用程序中有以下型号。(从技术上讲,这是mongoid gem,但我需要的是一个简单的rails答案,所以只需假设字段名在迁移中,而不是像在常规rails应用程序中那样在模型中) 型号: class Bid include Mongoid::Document field :amount belongs_to :item belongs_to :person accepts_nested_attributes_for :item, :person end class

我在拍卖应用程序中有以下型号。(从技术上讲,这是mongoid gem,但我需要的是一个简单的rails答案,所以只需假设字段名在迁移中,而不是像在常规rails应用程序中那样在模型中)

型号:

class Bid
  include Mongoid::Document
  field :amount
  belongs_to :item
  belongs_to :person
  accepts_nested_attributes_for :item, :person
end

class Person
  include Mongoid::Document
  field :name
  has_many :bids
end

class Item
  include Mongoid::Document
  field :item_description
  has_many :bids
end
路线:

resources :items do
  resources :bids
end

resources :people do
  resources :bids
end 
我可以创建一个嵌套表单,如中所示,用于单个关系,如“投标供应商”

如何以及在何处(最佳实践/或最容易的地方)创建嵌套表单以输入属于某个项目和某个人的投标