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属性?