Editing a form in nested_form gem

This is a very very naive and simple thing but I quite lost my time on this so I thought might be helpful.

Recently I was using the ‘nested_form’ gem by the great Ryan Bates (https://github.com/ryanb/nested_form). The form to create a new form works like a real gem without any effort.

Now, when I clicked on ‘edit’ link, it created some issues as the nested models didnt come.

I had a simple thing like each question has many answers. When I created a question, I added 5 answers to it but when I edited the question, no answers were visible.

The simple solution for this would be that the <% f.fields_for :answers do |an| %> line in your form would be without an equal to sign so just add it.

Thus, it looks like

<%= f.fields_for :answers do |an| %>

Thats all and it works like a charm!

Hope it helps.

Inheritance and Mixins

Some object-oriented languages (such as C++) support multiple inheritance, where a class can have more than one immediate parent,
inheriting functionality from each. Although powerful, this technique can be dangerous, because the inheritance hierarchy can become
ambiguous.
Other languages, such as Java and C#, support single inheritance. Here, a class can have only one immediate parent. Although cleaner
(and easier to implement), single inheritance also has drawbacks—in the real world objects often inherit attributes from multiple sources (a
ball is both a bouncing thing and a spherical thing, for example).

Ruby offers an interesting and powerful compromise, giving you the simplicity of single inheritance and the power of multiple inheritance. A
Ruby class has only one direct parent, so Ruby is a single-inheritance language. However, Ruby classes can include the functionality of
any number of mixins (a mixin is like a partial class definition). This provides a controlled multiple-inheritance-like capability with none of
the drawbacks.