9

1- 我安装了 gem bootstrap_form
2- 我在 application.css 中写了那行*= require bootstrap_form before the */
3- 在我的 html.erb

<%= bootstrap_form_for(@guardian, :url => student_guardians_path(@student),
html: { class: 'form-horizontal' },
method: :post) do |f| %>

我收到以下错误:undefined methodbootstrap_form_for' for #<#:0xb31a80c>`

4

4 回答 4

8

我遇到了同样的错误。通过替换修复它

gem 'bootstrap-form'

经过

gem 'bootstrap_form'

在我的gemfile

于 2014-01-25T09:00:42.250 回答
5

我也遇到了这个错误,直到我意识到我没有重新启动 rails 服务器。当我重新启动服务器时,错误消失了。

于 2014-02-18T11:09:57.563 回答
2

我最近遇到了这个问题,我的问题是捆绑安装似乎正在拉取 v3.0.0,但 GitHub 上的最新版本被列为 2.3.0。将我的 Gemfile 中的相应行更改为:

gem 'bootstrap_form', '~> 2.3.0'

修复了问题。

于 2015-09-22T13:46:30.367 回答
0

如@sunny1304 的评论所示,通过正确编写表单代码解决了这个问题bootstrap_form_for([@student,@guardian]。因此,如果现有答案都不适合您,这可能是一个提示或指导您的东西。

感谢其他贡献者,因为他们的回答帮助了像我这样面临问题的其他用户。

于 2019-01-18T08:46:21.963 回答