2012-04-11 63 views
6

我完全停留在這個錯誤。使用Rails 3.1試圖實現Formastic引導寶石和獲取錯誤:Formastic Bootstrap導軌錯誤 - 沒有這樣的文件來加載ButtonsHelpers

`':沒有這樣的文件來加載 - formtastic /助理/ 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 

回答

13

我有同樣的問題。 formtastic 2.2.0(昨天推)顯然最新的版本是與formtastic自舉

對於您必須指定的formtastic

早期版本不兼容,只需添加上述gem 'formtastic-bootstrap'

gem 'formtastic', " ~> 2.1.1" 

以下行它是formtastic的早期版本。

+0

只是我的運氣!謝謝。 – johnnewbie 2012-04-12 02:08:53

相關問題