2017-03-27 140 views
0

將應用程序從Rails 3.2升級到Rails 4.2.8時,ruby版本在2.3.2中保持不變。軟件包安裝和軟件包更新成功運行,沒有警告或錯誤。Rails 4升級中的Formtastic Gem問題

環境:窗戶,紅寶石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寶石的多個版本,這可能無法解決問題,甚至下降到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

好像你使用formtasticformtastic-bootstrap寶石。不幸的是formtastic-bootstrap與目前的formtastic版本不兼容,而且它似乎沒有維護,因爲它在過去兩年中沒有收到任何更新。

我看到兩個選項:像this answer提到

  1. 下調至formtastic~> 2.1.1
  2. 替換或分叉並修復formtastic-bootstrap以能夠向前移動。

我會選擇第二個選項。僅僅因爲它取決於一顆寶石(似乎無論如何都被遺棄)而使用舊的軟件堆棧,聽起來對我來說不是一個好計劃。

+0

我已經看到了答案,但我沒有使用formtastic-bootstrap寶石。將相關文件包含在我的項目文件夾中後,我正在使用引導程序。 gemfile.lock顯示formtastic僅取決於actionpack,正如我在qsn中提到的。 – Bijendra

+0

錯誤消息告訴你你的代碼中需要'formtastic/helpers/buttons_helper'(直接或在寶石中)。這個模塊在'formtastic'的新版本中不再存在。請將文件發佈到您需要的幫助程序或命名需要它的gem(或發佈您的Gemfile.lock)。 – spickermann

+0

我使用指向引用的錯誤堆棧跟蹤更新了我的qsn。這是從formtastic.rb調用的,我也看到了github頁面上的棄用消息,但是想知道爲什麼引用仍然保留在gem代碼 – Bijendra