我是第一次使用nested_form_for gem。我不知道这是一个问题还是使用不正确,但是出现“未定义的方法nested_form_for”错误。
如您所见,我有一个很正规的表格:
<%= 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 %>
顺便说一句,我安装了gem并运行:
rails generate nested_form:install command
以生成nested_form.js文件,该文件包含在我的jquery include(<%= javascript_include_tag :default, 'nested_form' %>
)之后的布局中。有人也使用这个 gem 吗?
谢谢!
最佳答案
一切看起来都正确,如果生成器运行了,则应该放置 gem 。自从将插件添加到Gemfile以来,您是否已重新启动服务器?
关于ruby-on-rails-3 - 无法使用nested_form_for gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5033864/