Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.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 Can';是否不能使用嵌套形式保存多个对象?_Ruby On Rails_Ruby_Ruby On Rails 3_Nested Forms - Fatal编程技术网

Ruby on rails Can';是否不能使用嵌套形式保存多个对象?

Ruby on rails Can';是否不能使用嵌套形式保存多个对象?,ruby-on-rails,ruby,ruby-on-rails-3,nested-forms,Ruby On Rails,Ruby,Ruby On Rails 3,Nested Forms,我使用的是nested_表单gem,具有以下表单: = simple_nested_form_for @profile do |f| = f.fields_for :person do |p| = p.fields_for :web_profiles do |e| = e.input :name = e.input :url = e.link_to_remove 'Remove' = p.link_to_add 'Add Web Profi

我使用的是
nested_表单
gem,具有以下表单:

= simple_nested_form_for @profile do |f|
  = f.fields_for :person do |p|
    = p.fields_for :web_profiles do |e|
      = e.input :name
      = e.input :url
      = e.link_to_remove 'Remove'
    = p.link_to_add 'Add Web Profile', :web_profiles

Person
  has_many :web_profiles
  has_one :profile
Profile
  belongs_to :person
WebProfile
  belongs_to :person
表单是正确生成的,但当我尝试添加第二个或更多的web配置文件时,在提交表单后,我只看到数据库中的最后一个web配置文件

Started POST "/profiles" for 127.0.0.1 at 2013-06-17 14:45:48 +0200
Processing by ProfilesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"x2EEQXF9Blnvp0Ib1HG9XjHtaCEHwCNaBzPnZwxnlbI=", "profile"=>{"person_attributes"=>{"gender"=>"", "title"=>"", "first_name"=>"Darek", "last_name"=>"", "birthday"=>"", "place_of_birth"=>"", "company_id"=>"", "web_profiles_attributes"=>{"1371473134262"=>{"name"=>"zzzz", "url"=>"aaaa.pl", "_destroy"=>"false"}}}, "available_at"=>"", "last_contact_at"=>"", "remind_at"=>"", "blacklisted"=>"0", "overall_rating"=>""}, "commit"=>"Create Profile"}
Redirected to http://0.0.0.0:3000/profiles/2
Completed 302 Found in 18ms (ActiveRecord: 1.1ms)

这是我添加两个web配置文件后的日志,但在
web\u profiles\u attributes
的参数中,我只看到一个web配置文件对象。

最近gem已更新,问题已停止


最近gem已更新,问题已停止


应该
f.fields\u for:web\u profiles
p.fields\u for?
web配置文件是属于person(通过嵌套表示)还是属于profile(您所做的)?链接是gem的一部分吗?如果您添加了几个web配置文件表单,您能确认它们的ID是否不同吗?对不起,我是从partials粘贴表单的。我更新了模型和关联。是否使用
接受嵌套属性的person类设置:web\u profiles
属性可访问:web\u profiles\u attributes
?是否应
f.fields\u for:web\u profiles
p.fields\u for?
web配置文件属于person(嵌套隐含)还是属于profile(您所做的)?链接是gem的一部分吗?如果您添加了几个web配置文件表单,您能确认它们的ID是否不同吗?对不起,我是从partials粘贴表单的。我更新了模型和关联。具有
接受嵌套属性的person类设置是否适用于:web\u配置文件
属性可访问:web\u配置文件\u属性