使用 Rails 4.0 强参数时,如何允许这样的 JSON?
{
"user":
{
"first_name":"Jello"
},
"users_to_employer":[
{
"start_date":"2013-09-03T16:45:27+02:00",
"end_date":"2013-09-10T16:45:27+02:00",
"employer":{"company_name":"Telenor"}
},
{
"start_date":"2013-09-17T16:45:27+02:00",
"end_date":null,
"employer":{"company_name":"Erixon"}
}
]
}
我试过了:
params.require(:users_to_employers => []).permit(
:start_date,
:end_date => nil,
:employer => [
:company_name
])
但它没有用。