【问题标题】:bootstrap_form error undefined methodbootstrap_form 错误未定义方法
【发布时间】:2013-06-27 17:35:15
【问题描述】:

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 #`

【问题讨论】:

  • 你在 Gemfile 中添加了 gem 吗?
  • 是但不在特定组中,只是写在我的gem文件顶部
  • 尝试 bootstrap_form_for([@student,@guardian]......并删除 url,你不需要它,因为你正在将表单与对象绑定。

标签: ruby-on-rails ruby-on-rails-3 forms


【解决方案1】:

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

gem 'bootstrap-form'

通过

gem 'bootstrap_form'

在我的gemfile

【讨论】:

  • 是的,这是我的问题。我可以发誓它在码头上说使用破折号而不是下划线。哇!
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

    gem 'bootstrap_form', '~> 2.3.0'
    

    解决了这个问题。

    【讨论】:

      【解决方案4】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-27
        相关资源
        最近更新 更多