Skip to content

Aug 15 / Rupak Ganguly

Tip: has_one and nested form/attributes

Although, the usage of nested forms with has_many associations is well documented, I found that especially the call that works for has_many associations do not work for has_one associations. For the code to work for has_one associations, use this instead:
E.g book.build_author where book has_one association to author.

Hope this helps.


leave a comment
  1. Pedro Coelho / Sep 8 2009

    Yes. It actually helped a lot. Thanks for the heads up!

  2. Rupak Ganguly / Sep 9 2009

    Glad it helped you. I try to post things that I got stuck and scratched my head. Good luck!

Leave a Comment