无法使用nested_form_for gem
我是第一次使用 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 并运行: railsgeneratenested_form:install 命令
来生成nested_form.js 文件,该文件包含在我的布局中jquery 包含(<%= javascript_include_tag :default, 'nested_form' %>
)。
有人也用这个宝石吗?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一切看起来都正确,如果发电机运行,宝石应该就位。将插件添加到 Gemfile 后,您是否重新启动了服务器?
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?