耙子流产了!未初始化的常数子弹

时间:2014-04-04 09:50:28

标签: ruby-on-rails ruby initialization constants

我的迁移问题非常烦人。

首先是错误消息:

rake db:migrate --trace
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake/alt_system.rb:32:in `<module:AltSystem>': Use RbConfig instead of obsolete and deprecated Config.
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake/alt_system.rb:32:in `<module:AltSystem>': Use RbConfig instead of obsolete and deprecated Config.
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:960:in `<module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config.
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:962:in `<module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config.
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:965:in `<module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config.
/usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:966:in `<module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config.
(in /Users/agstwn/Documents/WORK/hq_git/PS)
syck has been removed, psych is used instead
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant Bullet

这是我的--trace:

/config/initializers/const_missing.rb:12:in `const_missing_with_csv_export'
    /config/environments/development.rb:49:in `block (2 levels) in <top (required)>'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:34:in `call'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:42:in `each'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/activesupport-3.2.17/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `block in run_initializers'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /Users/agstwn/Documents/WORK/hq_git/PS/config/environment.rb:12:in `<top (required)>'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/application.rb:103:in `require_environment!'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/railties-3.2.17/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:636:in `call'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:631:in `each'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
    /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:607:in `block in invoke_prerequisites'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:604:in `each'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:596:in `block in invoke_with_call_chain'
    /usr/local/rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
    /usr/local/rvm/gems/ruby-2.0.0-p451/bin/rake:23:in `load'
    /usr/local/rvm/gems/ruby-2.0.0-p451/bin/rake:23:in `<main>'
    /usr/local/rvm/gems/ruby-2.0.0-p451/bin/ruby_executable_hooks:15:in `eval'
    /usr/local/rvm/gems/ruby-2.0.0-p451/bin/ruby_executable_hooks:15:in `<main>'

我不知道这个,我已经搜索了但我无法找到它。也许你们现在谈论这个?

/config/initializers/const_missing.rb

class << Object 

  def const_missing_with_csv_export(name) 
    if name.to_s =~ /^(?<resource_name_camelcase>.+)Csv(?:Import|Export)(?:Log|Job)/ 
      const_get $~['resource_name_camelcase'] + 'Controller' 
      const_get name 
    else 
      const_missing_without_csv_export(name) 
    end 
  end

  alias_method_chain :const_missing, :csv_export 
end

1 个答案:

答案 0 :(得分:0)

我已经用

解决了这个问题
uninitialized constant Bullet

当我之前运行bundle install时,它所说的开发中的gem并没有安装 所以再次重新运行bundle install。确保安装了我的子弹宝石。