2012-05-14 75 views
1

的Rails似乎沒有被加載雷寶石,因爲我開始了開發服務器時得到一個Uninitialized constant錯誤:Rails 3中沒有加載寶石

/home/my_app/config/initializers/kaminari_config.rb:1:in `<top (required)>': uninitialized constant Kaminari (NameError) 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/engine.rb:587:in `each' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/engine.rb:587:in `block in <class:Engine>' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/initializable.rb:30:in `instance_exec' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/initializable.rb:30:in `run' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/initializable.rb:55:in `block in run_initializers' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/initializable.rb:54:in `each' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/initializable.rb:54:in `run_initializers' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/application.rb:136:in `initialize!' 
from /home/ramses/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing' 
from /home/my_app/config/environment.rb:5:in `<top (required)>' 

不過,我包括它Gemfile,並且正在運行gem list也顯示它已安裝。有任何想法嗎?我該如何追蹤這個Uninitialized constant錯誤?

謝謝!

我的Gemfile: 源 'https://rubygems.org'

gem 'rails', '3.2.1' 

gem 'jquery-rails' 
gem 'blueprint-rails' 
gem 'mysql2' 
gem 'kaminari' 

group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem "therubyracer", :require => 'v8' 
    gem 'uglifier', '>= 1.0.3' 
end 

group :development do 
    gem 'rvm-capistrano' 
    gem 'capistrano' 
end 

gem list

$ gem list 
actionmailer (3.2.1) 
actionpack (3.2.2, 3.2.1) 
activemodel (3.2.2, 3.2.1) 
activerecord (3.2.1) 
activeresource (3.2.1) 
activesupport (3.2.2, 3.2.1) 
arel (3.0.0) 
blueprint-rails (0.1.2) 
builder (3.0.0) 
bundler (1.0.22 ruby, 1.0.21) 
capistrano (2.12.0) 
coffee-rails (3.2.2) 
coffee-script (2.2.0) 
coffee-script-source (1.2.0) 
daemon_controller (1.0.0) 
erubis (2.7.0) 
execjs (1.3.0) 
fastthread (1.0.7) 
highline (1.6.12) 
hike (1.2.1) 
i18n (0.6.0) 
journey (1.0.1) 
jquery-rails (2.0.0) 
jruby-jars (1.6.7) 
jruby-rack (1.1.4) 
json (1.6.5) 
kaminari (0.13.0) 
libv8 (3.3.10.4 x86-linux) 
mail (2.4.1) 
mime-types (1.17.2) 
multi_json (1.0.4) 
mysql2 (0.3.11) 
net-scp (1.0.4) 
net-sftp (2.0.5) 
net-ssh (2.3.0) 
net-ssh-gateway (1.1.0) 
passenger (3.0.11) 
polyglot (0.3.3) 
rack (1.4.1) 
rack-cache (1.1) 
rack-ssl (1.3.2) 
rack-test (0.6.1) 
rails (3.2.1) 
railties (3.2.1) 
rake (0.9.2.2) 
rdoc (3.12) 
rubyzip (0.9.6.1) 
rvm (1.11.3.3) 
rvm-capistrano (1.1.0) 
sass (3.1.14) 
sass-rails (3.2.4) 
sprockets (2.1.2) 
therubyracer (0.10.1) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10) 
tzinfo (0.3.31) 
uglifier (1.2.3) 

回答

1

我可以看到你using RVM to manage different ruby versions and different gemsets(具體到每個應用程序集寶石) 。那很棒。

但是你正在rvm之外運行gem命令 - 意味着它不一定顯示rvm爲你使用的特定ruby版本設置了什麼。這也可能是kaminari在您的機器上,但不在該應用程序的捆綁包中。

這可能只是因爲您已經切換RVM紅寶石而不運行軟件包。

您可以從您的項目根目錄運行bundle install並驗證是否爲該項目的捆綁包安裝了Kaminari?

+0

嗨凱文,根據你的建議,我跑了'rvm 1.9.2-p290 do gem list',並且在那裏顯示了kaminari。另外,運行'bundle install'也會顯示它已安裝 – Ramses

+0

你可以運行'bundle exec rails c'嗎? –

+0

不,它會拋出相同的錯誤'未初始化常量Kaminari(NameError)' – Ramses