Ask A Question

Notifications

You’re not receiving notifications from this thread.

Dynamic Nested Forms with Turbo Discussion

Thanks for this lesson, it's very helpful.

One small tip in case anybody else runs into an error about UnknownAttributeError when using this approach for accepts_nested_attributes on an association that uses has_one instead of has_many. In the has_one setup, the parameters hash does not need the "id" used in the fields_for() call. If you include it then you get the UnknownAttributeError because of the id. This is nothing to do with turbo and can be reproduced in the rails console.

So, if using has_many, then include the "id"s in the fields_for.

If using has_one, do not!

Reply

Hey Sean! Glad to hear that you found this lesson helpful. Also, thanks a bunch for sharing your tip about doing this with has_one relationships! I'm sure that will come in handy for folks.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.