启动 Rails 开发服务器时出现错误。我运行 rails 3.0.6 和 ruby 1.8.7 (2012-06-29 patchlevel 370) [i686-linux]
我执行 rails 时控制台输出是这样的
=> Booting Mongrel
=> Rails 3.0.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
host is not a valid option for Mongo::Connection
我主要关心的是这个错误“主机不是 Mongo::Connection 的有效选项”。我集成了 devise 1.5.2 以通过 Omniauth 运行 Facebook、Twitter 和 LinkedIn 登录,现在出现了这个 mongoDB 错误。
我在这个 Rails 应用程序中使用的 GemFile。
source 'http://rubygems.org'
gem 'rails', '3.0.6'
gem 'rake', '0.8.7'
gem 'mysql'
gem 'mysql2', "0.2.11"
gem 'mongrel'
gem 'jquery-rails', '>= 0.2.7'
gem 'active_scaffold_vho'
gem 'inherited_resources', '~> 1.2.1'
gem 'has_scope', '~> 0.5.0'
gem 'json_pure'
gem 'formtastic', '~> 1.2.3'
gem "devise", "1.5.2"
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-linkedin'
gem 'omniauth-openid'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'uuidtools', '~> 2.1.2'
gem 'capistrano', '~> 2.6.0'
gem 'cgi_multipart_eof_fix'
gem 'fastthread'
gem 'mongoid', "~>2.0" #Mongoid
gem 'bson_ext', "~>1.3" #Mongoid
gem 'redis', "~> 2.2.0"
gem 'resque'
gem 'resque-scheduler'
gem 'SystemTimer', "~> 1.2.3"
gem 'ar_mailer_rails3'
gem 'lazy_high_charts', "~> 1.1.1"
gem 'rails-breadcrumbs', "~> 1.0.0"
gem 'curb'
gem 'geonames', "~> 0.2.2"
gem 'activemerchant'
gem 'savon', "~> 0.9.7"
gem 'rack-ssl'
gem 'state_machine'
gem "http_accept_language", '~> 1.0.2'
gem 'recurly', '~> 2.1.0'
gem 'newrelic_rpm'
group :test, :development do
gem 'rspec-rails', "~> 2.8"
gem 'rspec-mocks', "~> 2.8"
gem 'capybara', "~> 0.4.1.2"
gem 'database_cleaner', "~> 0.6.7 "
gem 'cucumber', "~> 0.10.2"
gem 'spork', "~> 0.9.0"
gem 'launchy', "~> 0.4.0"
gem 'machinist', "~> 1.0.6"
gem 'factory_girl_rails', "1.3.0"
gem 'faker', "~> 0.9.5"
gem 'email_spec'
gem 'rails-erd'
gem 'ruby-debug'
end
group :development do
gem "hirb"
gem "awesome_print"
end
mongoid.yml 文件如下:
defaults: &defaults
host: localhost
database: teenscrio
development:
<<: *defaults
database: teenscrio_dev
staging:
<<: *defaults
database: teenscrio_stg
test:
<<: *defaults
database: teenscrio_tst
# set these environment variables on your prod server
production:
host: <%= ENV['MONGOID_HOST'] %>
port: <%= ENV['MONGOID_PORT'] %>
username: <%= ENV['MONGOID_USERNAME'] %>
password: <%= ENV['MONGOID_PASSWORD'] %>
database: <%= ENV['MONGOID_DATABASE'] %>
为什么现在出现这个错误?devise和mongoid有什么关系?我该如何解决这个问题?