本文介绍了Formastic Bootstrap Rails 错误 - 没有可以加载 ButtonsHelpers 的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我完全被这个错误困住了.使用 Rails 3.1 尝试实现 Formastic Bootstrap gem 并出现错误:
I'm completely stuck on this error. Using Rails 3.1 trying to implement Formastic Bootstrap gem and getting error:
`': 没有要加载的文件 -- 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 不兼容
I had same issue. Apparently latest release of formtastic 2.2.0 (pushed yesterday) is not compatible with formtastic-bootstrap
为此,您必须指定早期版本的 formtastic
For that you have to specify earlier version of formtastic
只需在 gem 'formtastic-bootstrap'
gem 'formtastic', " ~> 2.1.1"
它是 formtastic 的早期版本.
it is little earlier version of formtastic.
这篇关于Formastic Bootstrap Rails 错误 - 没有可以加载 ButtonsHelpers 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!