Nested Object Forms with has_one Relation
Rails 2.3 has a good solution for multi model forms. But there is not much examples of how to use accepts_nested_attributes_for with has_one relation.
Assume that we have a Book model which has one Author.
Controller :
View:
No special action is needed for create method of BooksController, attr_accessible is not necessary for Book model. Just don’t forget to add the second parameter (@book) of form_for and build your nested object (@book.build_author).
3 Comments
[...] Nested Object Form with has_one Relation Share and Enjoy: [...]
Your property is valueble for me. Thanks!?-
Touchdown! That’s a raelly cool way of putting it!