Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3.1 Formastic Bootstrap Rails错误-没有这样的文件来加载按钮帮助程序_Ruby On Rails 3.1_Twitter Bootstrap_Formtastic - Fatal编程技术网

Ruby on rails 3.1 Formastic Bootstrap Rails错误-没有这样的文件来加载按钮帮助程序

Ruby on rails 3.1 Formastic Bootstrap Rails错误-没有这样的文件来加载按钮帮助程序,ruby-on-rails-3.1,twitter-bootstrap,formtastic,Ruby On Rails 3.1,Twitter Bootstrap,Formtastic,我完全被这个错误迷住了。使用Rails 3.1尝试实现Formastic Bootstrap gem并出现错误: `:没有这样的文件要加载--formtastic/helpers/buttons\u helper(加载错误) Application.css *= require formtastic *= require formtastic-bootstrap Gemfile group :assets do gem 'sass-rails', " ~> 3.1.0" gem

我完全被这个错误迷住了。使用Rails 3.1尝试实现Formastic Bootstrap gem并出现错误:

`:没有这样的文件要加载--formtastic/helpers/buttons\u helper(加载错误)

Application.css

*= require formtastic
*= require formtastic-bootstrap
Gemfile

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
  gem 'less-rails-bootstrap'
    gem 'bootstrap-sass'
end
formastic.rb

Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder

gem 'formtastic'

gem 'formtastic-bootstrap'
按钮\u辅助对象

module FormtasticBootstrap
  module Helpers
    module ButtonsHelper

      include Formtastic::Helpers::ButtonsHelper

      def buttons(*args, &block)

        html_options = args.extract_options!
        html_options[:class] ||= "actions"

        if html_options.has_key?(:name)
          ActiveSupport::Deprecation.warn('The :name option is not supported')
        end

        if block_given?
          template.content_tag(:div, html_options) do
            yield
          end          
        else
          args = [:commit] if args.empty?
          contents = args.map { |button_name| send(:"#{button_name}_button") }
          template.content_tag(:div, html_options.except(:builder, :parent, :name)) do
            Formtastic::Util.html_safe(contents.join)
          end
        end

      end

      def commit_button(*args)
        options = args.extract_options!
        text = options.delete(:label) || args.shift

        text = (localized_string(commit_button_i18n_key, text, :action, :model => commit_button_object_name) ||
                Formtastic::I18n.t(commit_button_i18n_key, :model => commit_button_object_name)) unless text.is_a?(::String)

        button_html = options.delete(:button_html) || {}
        button_html.merge!(:class => [button_html[:class], "btn commit", commit_button_i18n_key].compact.join(' '))

        # TODO We don't have a wrapper. Add deprecation message.
        # wrapper_html = options.delete(:wrapper_html) || {}
        # wrapper_html[:class] = (commit_button_wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')

        accesskey = (options.delete(:accesskey) || default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
        button_html = button_html.merge(:accesskey => accesskey) if accesskey

        Formtastic::Util.html_safe(submit(text, button_html))
      end

    end
  end
end
模块FormtasticBootstrap
模块助手
模块按钮帮助器
包括Formtastic::Helpers::ButtonsHelper
def按钮(*参数和块)
html\u options=args.extract\u options!
html|U选项[:类]| |=“操作”
如果html_options.has_key?(:name)
ActiveSupport::Deprecation.warn('name选项不受支持')
结束
如果给出了block_?
template.content\u标记(:div,html\u选项)do
产量
结束
其他的
args=[:提交]如果args.empty?
contents=args.map{|按钮|名称|发送(:“{按钮|名称}|按钮”)}
template.content\u标记(:div,html\u选项。除了(:builder,:parent,:name))之外
Formtastic::Util.html\u-safe(contents.join)
结束
结束
结束
def提交按钮(*args)
选项=args.extract\u选项!
text=选项。删除(:label)| | args.shift
text=(本地化的字符串(commit\u按钮\u i18n\u键,text,:action,:model=>commit\u按钮\u对象\u名称)||
Formtastic::I18n.t(commit_按钮_I18n_键,:model=>commit_按钮_对象_名称),除非text.is_是?(::字符串)
button_html=options.delete(:button_html)|{}
按钮_html.merge!(:class=>[按钮html[:class],“btn提交”,提交按钮i18n键].compact.join(“”))
#我们没有包装纸。添加弃用消息。
#wrapper_html=options.delete(:wrapper_html)|{}
#包装器\u html[:类]=(提交按钮\u包装器\u html\u类accesskey)如果accesskey
Formtastic::Util.html\u safe(提交(文本、按钮\u html))
结束
结束
结束
结束

我也有同样的问题。显然,formtastic 2.2.0的最新版本(昨天推出)与formtastic bootstrap不兼容

为此,您必须指定formtastic的早期版本

只需在gem'formtastic bootstrap'上方添加以下行

gem 'formtastic', " ~> 2.1.1"
这是formtastic的早期版本