我試圖在我的控制器中接收一些參數,但是我在允許它們時遇到了問題。這是我的請求負載:導軌不允許的參數
{
contacts: [{
id: null,
address: null,
business: "Company",
cellphone: "",
city: null,
country: null,
email: "[email protected]"
}],
name: "Entity1"
}
在我的控制,我定義:
def update_params
params.permit(
:name,
contacts_attributes: [
:id, :first_name, :last_name, :email, :business, :position, :telephone,
:cellphone, :address, :city, :state, :country
]
)
end
但是,當我打電話update_params方法,只有:名稱是允許的。聯繫人是不允許的。我錯過了什麼嗎?
嘗試'聯繫人:',而不是'contacts_attributes:' – Pavan
允許其在模型還 – Mukesh
檢查,如果你在你的模型中使用attr_accessible也strong_params在控制器如果是的話,那麼請從模型中取出attr_accessible在軌道4 還要檢查如果您在模型中使用了accept_nested_attributes_for聯繫人 –