1
我使用Simple_form與Decent_exposure工作,Strong_parameters我有以下的設置,我可以張貼到家庭,但沒有被髮布到鄰居嵌套屬性不Simple_form,Decent_exposure,Strong_parameters
模型
class Household < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
has_many :neighbors
accepts_nested_attributes_for :neighbors
查看
= simple_nested_form_for household do |f|
= f.input :household_name
= f.simple_fields_for :neighbor, Neighbor.new do |neighbor_form|
= neighbor_form.input :first_name
= neighbor_form.input :middle_name
= neighbor_form.input :last_name
= neighbor_form.input :address
= f.button :submit
基於以下從我的日誌它看起來像窗體工作,但它不是保存到鄰居嵌套模型 - 我已經嘗試了simple_fields_for:neighbor do和simple_fields_for:neighbor,Neighbor.new希望創建一個新的鄰居會有所幫助,但事實並非如此。
Parameters:{"utf8"=>"✓",
authenticity_token"=>"cVTteqPFa0JMoFi/ys0wAmNIQghubADv5lbPBr6hyq0=",
"household"=> {"household_name"=>"Deew", "neighbor"=>{"first_name"=>"Bill",
"middle_name"=>"", "last_name"=>"Ew", "street"=>"we"}}, "commit"=>"Create Household"}
(0.1ms) begin transactionSQL (0.7ms) INSERT INTO "households" ("created_at",
"household_name", "name", "updated_at") VALUES (?, ?, ?, ?)
[["created_at", Sun, 03 Feb 2013 03:02:56 UTC +00:00], ["household_name", "Deew"],
["name", nil], ["updated_at", Sun, 03 Feb 2013 03:02:56 UTC +00:00]](0.8ms)
commit transaction
好笑。這是我嘗試使用Google搜索時遇到的第一個問題。 – msergeant