Accepts_nested_attributes_for and active resource

I would like to use accepts_nested_attributes_for with the active resource. Is it possible? I experimented in the console and did work with nested attributes, however, nested models are not created because foreign_key is never set.

For instance,

I have a custom class that accepts_nested_attributes_for: credentials. Json meets as

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

so I copied this to the console, but the credential check failed because user_id is never set.

Is there any way to do this?

+3
source share

Source: https://habr.com/ru/post/1755410/


All Articles