开发者

Can't use the nested_form_for gem

开发者 https://www.devze.com 2023-02-11 12:37 出处:网络
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 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 :descripti开发者_Python百科on %> <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!


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消