Rails似乎没有加载Kaminari gem,因为我在启动开发服务器时遇到Uninitialized constant
错误:
/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)
答案 0 :(得分:1)
我可以看到你是using RVM to manage different ruby versions and different gemsets(特定于每个应用程序的宝石集)。那很好。
但是你在rvm之外运行gem
命令 - 意味着它不一定显示rvm为你正在使用的特定ruby版本设置了什么。也可能是kaminari在你的机器上,但不在该应用程序的包中。
可能只是你已经切换了RVM rubies并且没有运行bundle。
您可以从项目根目录运行bundle install
并验证是否为该项目的捆绑包安装了Kaminari?