How do I create a nested form using Mongoid embedded resources in Rails 3? How do I create a nested form using Mongoid embedded resources in Rails 3? mongodb mongodb

How do I create a nested form using Mongoid embedded resources in Rails 3?


When you show the nested form, try using (notice the equals):

<%= f.fields_for

Instead of just

<% f.fields_for

See this similar question.


I had a very similar issue recently. I found this similar question posted on the Mongoid issue tracker on Github to be very helpful:

https://github.com/mongoid/mongoid/issues/1468#issuecomment-6898898

The skinny is that the line

= f.fields_for :ingredients do |builder|

should look like this:

= f.fields_for @recipe.ingredients do |builder|