I am getting an error when I start my rails development server. I run rails 3.0.6 and ruby 1.8.7 (2012-06-29 patchlevel 370) [i686-linux]
The console output is like this when I execute rails s
=> 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
My main concern is this error “host is not a valid option for Mongo::Connection”. I integrate devise 1.5.2 to run Facebook, Twitter and LinkedIn login via Omniauth and this mongoDB error is appearing now.
The GemFile I use in this Rails App.
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
The mongoid.yml file is as follows:
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'] %>
Why this error is appearing now? What is the relation between devise and mongoid? How can I fix this issue?
You need to reconsider how your initializing
Mongo::Connection. You seem to be supplying the host incorrectly in the options, whereas it has to be passed directly to the initializer or specified in the environment.I’m assuming there’s some difference between your development and production environment with regards to how your constructing your MongoDB connection that’s leading to the exception your encountering.