加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3.1 – Formastic Bootstrap Rails错误 – 没有这

发布时间:2020-12-16 21:54:36 所属栏目:百科 来源:网络整理
导读:我完全坚持这个错误.使用Rails 3.1试图实现Formastic Bootstrap gem并获得错误: `’:没有这样的文件要加载 – formtastic / helpers / buttons_helper(LoadError) Application.css *= require formtastic*= require formtastic-bootstrap 的Gemfile group
我完全坚持这个错误.使用Rails 3.1试图实现Formastic Bootstrap gem并获得错误:

`’:没有这样的文件要加载 – formtastic / helpers / buttons_helper(LoadError)

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'

buttons_helper

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

解决方法

我有同样的问题.显然最新发布的formtastic 2.2.0(昨天推出)与formtastic-bootstrap不兼容

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

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

gem 'formtastic'," ~> 2.1.1"

它是formtastic的早期版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读