如果我有管理员模型,Sidekiq无法启动

时间:2014-07-07 05:07:11

标签: ruby ruby-on-rails-4 devise backgroundworker sidekiq

我使用sidekiq处理后台作业,这不是我第一次使用sidekiq。

问题:

如果我有一个名为admin的设计模型,Sidekiq将无法启动。

class Admin < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :registerable, :timeoutable and :omniauthable
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
end

如果我评论这个“admin”模型类,那么sidekiq将正常启动按预期工作。目前我正在使用sidekiq默认配置。

错误Backtrace:

bundle exec sidekiq
Admin is not a class
/home/ninja/workspace/howismyschool/app/models/admin.rb:1:in `<top (required)>'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:in `load'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:443:in `block in load_file'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:633:in `new_constants_in'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:442:in `load_file'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:342:in `require_or_load'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:307:in `depend_on'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:225:in `require_dependency'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:468:in `block (2 levels) in eager_load!'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:467:in `each'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:467:in `block in eager_load!'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:465:in `each'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:465:in `eager_load!'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/engine.rb:346:in `eager_load!'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/application/finisher.rb:58:in `each'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
/home/ninja/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
/home/ninja/workspace/howismyschool/config/environment.rb:5:in `<top (required)>'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/sidekiq-3.2.0/lib/sidekiq/cli.rb:230:in `boot_system'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/sidekiq-3.2.0/lib/sidekiq/cli.rb:49:in `run'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/gems/sidekiq-3.2.0/bin/sidekiq:8:in `<top (required)>'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/bin/sidekiq:23:in `load'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/bin/sidekiq:23:in `<main>'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/bin/ruby_executable_hooks:15:in `eval'
/home/ninja/.rvm/gems/ruby-2.1.2@howismyschoolisdoing/bin/ruby_executable_hooks:15:in `<main>'

应用程序环境:

  • ruby​​ 2.1.2
  • rails 4.1.4
  • Ubuntu 14.04

1 个答案:

答案 0 :(得分:1)

该错误与sidekiq无关。 is not a class异常最有可能是由命名冲突引起的(您在某处定义了常量Admin)。检查项目是否为Admin常量并重命名。

如何在控制台(irb)中重现错误:

1.9.3-p448 :001 > A = 1
 => 1
1.9.3-p448 :002 > class A
1.9.3-p448 :003?> end
TypeError: A is not a class