Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use the nested_form_for gem

I am using the nested_form_for gem for the first time. I don't know if this is an issue or if I am using it wrong, but I am getting an "undefined method nested_form_for" error. I have a pretty regular form as you can see:

  <%= nested_form_for @user do |f| %>
        <%= f.fields_for :godfathers do |godfather_form| %>
            <%=  godfather_form.label :name %> <br/>
            <%=  godfather_form.text_field :name %> <br/>
            <%=  godfather_form.label :description %> <br/>
            <%=  godfather_form.text_field :description %> <br/>
            <%=  godfather_form.link_to_remove "Remove this godfather" %>
        <% end %>
       <%= f.link_to_add "Add a godfather", :godfathers %>
   <% end %>

By the way, I installed the gem and ran the: rails generate nested_form:install command to generate the nested_form.js file that I included in my layout after the jquery inclusion(<%= javascript_include_tag :default, 'nested_form' %>).

Anyone using this gem as well?

Thanks!

like image 836
Amokrane Chentir Avatar asked Feb 17 '11 19:02

Amokrane Chentir


1 Answers

Everything looks right and if the generator ran the gem should be in place. Have you restarted your server since adding the plugin to your Gemfile?

like image 74
Mat Schaffer Avatar answered Nov 01 '22 01:11

Mat Schaffer