Daryl
unread,Apr 9, 2011, 4:10:22 AM4/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mongoid
I've got a padrino app I've been running locally with MongoDB and have
attempted to move it to Heroku using Mongoid 2.0.0 and connect to
MongoHQ (seemed like a good idea). Been absolutely banging my head as
to why this is not working.
#database.rb
require 'uri'
if ENV["MONGOHQ_URL"]
mongo_uri = URI.parse(ENV["MONGOHQ_URL"])
ENV['MONGOID_HOST'] = mongo_uri.host
ENV['MONGOID_PORT'] = mongo_uri.port.to_s
ENV["MONGOID_USERNAME"] = mongo_uri.user
ENV['MONGOID_PASSWORD'] = mongo_uri.password
ENV['MONGOID_DATABASE'] = mongo_uri.path.gsub("/", "")
else
host = 'localhost'
port = Mongo::Connection::DEFAULT_PORT
database_name = case Padrino.env
when :development then 'tweetup_dev'
when :production then 'tweetup'
when :test then 'tweetup_test'
end
end
Both insertions via a rake task (to test for db connectivity) and the
app trying to pull from the db in heroku continually fail with this
error:
2011-04-09T08:02:29+00:00 app[web.1]: Mongoid::Errors::InvalidDatabase
- Database should be a Mongo::DB, not NilClass.:
2011-04-09T08:02:29+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/
gems/mongoid-2.0.0/lib/mongoid/config.rb:195:in `master'
2011-04-09T08:02:29+00:00 app[web.1]: (eval):2:in `master'
I can confirm the database is up and running on MongoHQ and I've
created a document in it which works, so absolutely stumped at this
point as to what the problem is. Using heroku config --long gives me
the paramaters for the mongodb anf I can remote connect to it via
MongoHQ to brwose and enter data.
Anybody have any clues or pointers as to what I may be doing wrong
here? Have the various config options changed in mongoid as of 2.0.0?
I should mention this is the first time I've tried to use MongoHQ with
Mongoid.
At this point, I'm about to punt, spin up an Amazon EC2 instance and
just use a local MongoDB.