Formtastic Gem与Rails 4升级有关

时间:2017-03-27 05:44:10

标签: ruby ruby-on-rails-4 rubygems formtastic ruby-on-rails-4.2

在将应用程序从Rails 3.2升级到Rails 4.2.8时,ruby版本在2.3.2保持不变。捆绑安装和捆绑更新正在成功运行,没有任何警告或错误。

环境: windows,ruby 2.3.2

执行任何rake任务或启动服务器中断,找到以下错误,

Rake任务中断:

  Error:[rake --tasks] C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb:52: warning: circular argument reference - name
  rake aborted!
  LoadError: cannot load such file -- formtastic/helpers/buttons_helper
  C:/workspace/project1/lib/ext/gems/formtastic/formtastic.rb:13:in `<module:Formtastic>'
  C:/workspace/project1/lib/ext/gems/formtastic/formtastic.rb:1:in `<top (required)>'
  C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
  C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'

开发服务器启动抛出错误:

C:/workspace/project1/lib/ext/gems/formtastic/formtastic.rb:13:in `<module:Formtastic>': cannot load such file -- formtastic/helpers/buttons_helper (LoadError)
  from C:/workspace/projects/CosmoD2Upgrade/director2/lib/ext/gems/formtastic/formtastic.rb:1:in `<top (required)>'
  from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
  from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
  from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
  from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'

的Gemfile:

   # form builder
   gem 'formtastic'

Gemfile.lock的

formtastic (3.1.5)
  actionpack (>= 3.2.13)

我尝试过多个版本的Formtastic gem,即使是2.0版也无法解决问题。如果有任何补丁或修补程序可用,请告诉我。

更新:包括佣金失败的错误堆栈跟踪

Error:[rake --tasks] C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/cucumber-1.1.9/lib/cucumber/ast/feature_element.rb:52: warning: circular argument reference - name
    rake aborted!
    LoadError: cannot load such file -- formtastic/helpers/buttons_helper
    C:/workspace/project/lib/ext/gems/formtastic/formtastic.rb:13:in `<module:Formtastic>'
    C:/workspace/project/lib/ext/gems/formtastic/formtastic.rb:1:in `<top (required)>'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    C:/workspace/project/config/application.rb:9:in `block in <top (required)>'
    C:/workspace/project/config/application.rb:9:in `each'
    C:/workspace/project/config/application.rb:9:in `<top (required)>'
    C:/workspace/project/Rakefile:4:in `require'
    C:/workspace/project2/Rakefile:4:in `<top (required)>'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:686:in `raw_load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:96:in `block in load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:95:in `load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:79:in `block in run'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
    C:/workspace/project/bin/rake:4:in `<main>'
    Polyglot::PolyglotLoadError: Failed to load C:/workspace/project/lib/ext/gems/formtastic/formtastic.rb using extensions rb, treetop, tt
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:55:in `load'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:68:in `rescue in require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
    C:/workspace/project/config/application.rb:9:in `block in <top (required)>'
    C:/workspace/project/config/application.rb:9:in `each'
    C:/workspace/project/config/application.rb:9:in `<top (required)>'
    C:/workspace/project/Rakefile:4:in `require'
    C:/workspace/project/Rakefile:4:in `<top (required)>'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:686:in `raw_load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:96:in `block in load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:95:in `load_rakefile'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:79:in `block in run'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
    C:/workspace/projects/bin/rake:4:in `<main>'

错误指向以下文件和buttonhelper调用。

    .....  
    Line no 13:
    module Helpers::ButtonsHelper
      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], commit_button_i18n_key].compact.join(' '))

        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
    .....

1 个答案:

答案 0 :(得分:1)

您似乎使用formtasticformtastic-bootstrap宝石。遗憾的是formtastic-bootstrap与当前formtastic版本不兼容,而且似乎没有维护,因为它在过去两年内没有收到任何更新。

我看到两个选项:

  1. 降级为formtastic中提到的~> 2.1.1 formtastic-bootstrap
  2. 替换或分叉并修复vectorAdd以便能够向前移动。
  3. 我会选择第二种选择。使用一个旧的软件堆栈只是因为它依赖于一个宝石(似乎无论如何都被抛弃)对我来说听起来不是一个好计划。