开发者

accepts_nested_attributes_for and Active Resource

开发者 https://www.devze.com 2023-01-08 12:27 出处:网络
I\'d like to use accepts_nested_attributes_for with Active Resource.Is this possible?I have been experimenting in console and passing in nested attributes works, however the nested models fail to crea

I'd like to use accepts_nested_attributes_for with Active Resource. Is this possible? I have been experimenting in console and passing in nested attributes works, however the nested models fail to create because the foreign_key is never set.

For example,

I have a user class that accepts_nested_attributes_for 开发者_高级运维:credentials. The JSON comes across as

"user" => { "name" => "Joe", "credentials" => ["username" => "joe", "password" => "password"]}

, so I copied that into console, but the credential validation fails since user_id is never set.

Is there a way to do this?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号