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.

7 responses to “Editing a form in nested_form gem

  1. Greetings from Los angeles! I’m bored to tears aat work so
    I decided to check out your site on my iphone during lunch break.
    I love the knowledge you present here aand can’t wait to
    take a loolk whe I get home. I’m amazed at how fast your blog loaded on my mobile ..
    I’m not even usijng WIFI, just 3G .. Anyhow, superb blog!

  2. Wonderful blog! Do you have any recommendations for aspiring writers?

    I’m planning to start my own site soon but I’m a little lost
    on everything. Would you advise starting with
    a free platform like WordPress or go for a paid option? There
    are so many options out there that I’m totally confused ..
    Any suggestions? Thanks!

  3. This is very fascinating, You’re an overly professional blogger.

    I’ve joined your feed and sit up for in quest of more of your great post.

    Additionally, I have shared your web site in my social networks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s