How to Use Mongoid on Rails?
I've been tryi开发者_开发问答ng to use Mongoid with Rails on Ubuntu. I have installed mongoDB via apt-get. But when I try to run the rails server, I get this error:
/home/myusername/.rvm/gems/ruby-1.9.2-p180@mysite/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
I am just new to using Mongoid, any help will be appreciated. Thanks a lot in advance!
As Piotr says you need to start the Mongo DB server. If you want to quickly test this, run mongod
from a shell.
You need to start MongoDB server. I don't know exactly how to manage services in Ubuntu, but somewhere in /etc/rc.d or /etc/init.d you should have the mongodb script, run it with 'start' argument. I think the default configuration should do for your setup, but check if you have config/mongoid.yml in your Rails app. It should contain something like:
development:
host: localhost
database: app_development
test:
host: localhost
database: app_test
# set these environment variables on your prod server
production:
[...]
精彩评论