0

这个问题可能很容易解决,但不知何故我找不到解决方案。

Authlogic 和 Devise 都会发生这种情况。我一直在用头撞墙很长时间,以至于我实际上撕掉了 Authlogic 并重新启动了 Devise——但遇到了同样的问题。

在开发上一切都很好。

但是,当我开始生产时,每当我尝试 rake db:seed 或运行控制台时都会得到这个。这也显示我重新启动服务器和我的 gemfile。

为什么生产看不到宝石?它似乎能够看到其他宝石就好了。

您看到的 gem 是 Github 版本——这是推荐的修复程序,对我不起作用。我使用默认版本和强制特定版本得到相同的结果。

Authlogic 和 Devise 都存在相同问题的事实似乎表明我的生产配置存在问题?除了 Gemfile,它还能是什么?

开发 - Rails 3.0.4、1.9.2p136 产品 - Rails 3.0.4、1.9.2p0

最后的手段是升级 Ruby 以使它们匹配,但我怀疑这是问题所在,由于某些原因,我不会在这里进行大量工作。

ops@lightserve2:/home/proj/current$ touch tmp/restart.txt 

ops@lightserve2:/home/proj/current$ r c
/home/darkserve/releases/20110217175218/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `each'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `block in <class:Engine>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `run'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `each'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:134:in `initialize!'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
    from /home/darkserve/releases/20110217175218/config/environment.rb:5:in `<top (required)>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:103:in `require_environment!'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:22:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'



ops@lightserve2:/home/darkserve/current$ cat Gemfile.lock 
GIT
  remote: http://github.com/JonasNielsen/nifty-generators.git
  revision: 432d05d55b55e030d6c16b9d71b392181bca45f8
  specs:
    nifty-generators (0.4.3)

GIT
  remote: http://github.com/plataformatec/devise.git
  revision: 7113beac81a12da06be2d08bbfaec79017e9fdbf
  specs:
    devise (1.2.rc)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)

GEM
  remote: http://rubygems.org/
  specs:
    aaronh-chronic (0.3.9)
    abstract (1.0.0)
    actionmailer (3.0.4)
      actionpack (= 3.0.4)
      mail (~> 2.2.15)
    actionpack (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.4)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.13)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.4)
      activesupport (= 3.0.4)
      builder (~> 2.1.2)
      i18n (~> 0.4)
    activerecord (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
      arel (~> 2.0.2)
      tzinfo (~> 0.3.23)
    activeresource (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
    activesupport (3.0.4)
    arel (2.0.8)
    bcrypt-ruby (2.1.4)
    builder (2.1.2)
    capistrano (2.5.19)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.0.0)
    crack (0.1.8)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    foreigner (0.9.1)
    haml (3.0.25)
    haml-rails (0.3.4)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      haml (~> 3.0)
      railties (~> 3.0)
    highline (1.6.1)
    hpricot (0.8.3)
    httparty (0.7.4)
      crack (= 0.1.8)
    i18n (0.5.0)
    json (1.5.1)
    mail (2.2.15)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mash (0.1.1)
    mime-types (1.16)
    mocha (0.9.12)
    mysql2 (0.2.6)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.1.0)
    net-ssh-gateway (1.0.1)
      net-ssh (>= 1.99.1)
    nokogiri (1.4.4)
    oauth (0.4.4)
    orm_adapter (0.0.4)
    polyglot (0.3.1)
    rack (1.2.1)
    rack-mount (0.6.13)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.4)
      actionmailer (= 3.0.4)
      actionpack (= 3.0.4)
      activerecord (= 3.0.4)
      activeresource (= 3.0.4)
      activesupport (= 3.0.4)
      bundler (~> 1.0)
      railties (= 3.0.4)
    railties (3.0.4)
      actionpack (= 3.0.4)
      activesupport (= 3.0.4)
      rake (>= 0.8.7)
      thor (~> 0.14.4)
    rake (0.8.7)
    ruby-freshbooks (0.4.0)
      builder (>= 2.1.2)
      httparty (>= 0.5.0)
    ruby_parser (2.0.5)
      sexp_processor (~> 3.0)
    sexp_processor (3.0.5)
    simple_form (1.3.1)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.24)
    warden (1.0.3)
      rack (>= 1.0.0)
    whenever (0.6.2)
      aaronh-chronic (>= 0.3.9)
      activesupport (>= 2.3.4)
    yammer4r (0.1.5)
      json (>= 1.1.7)
      mash (>= 0.0.3)
      oauth (>= 0.3.5)

PLATFORMS
  ruby

DEPENDENCIES
  bcrypt-ruby
  capistrano
  devise!
  foreigner
  haml
  haml-rails
  hpricot
  mocha
  mysql2
  nifty-generators!
  nokogiri
  rails (= 3.0.4)
  ruby-freshbooks
  ruby_parser
  simple_form
  whenever
  yammer4r
4

2 回答 2

0

万一……

  1. 您尚未在生产环境中运行 bundle(不太可能)
  2. 你有你的gemfile分成几组 - 你会看到这样的

宝石文件

group :development do
     gem 'devise'
end
于 2011-02-20T06:13:08.217 回答
0

问题原来是这个切片上安装了另一个 rails 应用程序,并且由于配置错误,rake/rails 在运行时试图调用另一个应用程序的 rake/rails 脚本。

通过在我的应用程序的 /script 目录中强制使用 rails 脚本,问题在短期内得到了解决。例如

ruby script/rails console

代替

rails console

但是,我没有找到一种方法来轻松地强制自己复制 rake。

于 2011-02-20T13:43:58.397 回答