I use something like the following:
db = Mongo::Connection.new(ENV['DB_HOST'],
ENV['DB_PORT']).db(ENV['DB_DATABASE'])
auth = db.authenticate(ENV['DB_USER'], ENV['DB_PASS'])
if auth
puts "authenticated"
else
fail "failed authentication"
end
On Fri, Jul 30, 2010 at 2:56 PM, Ginny Hendry <[email protected]> wrote:
> My first deployment with MongoHQ and Sinatra (Ruby 1.9.1) gets
> "Internal Server Error". I used the suggested connection code like
> this:
>
> include Mongo
> def initialize
> if settings.environment == :development
> @db = Connection.new.db('inp-dev')
> else
> uri = URI.parse(ENV['MONGOHQ_URL'])
> conn = Connection.from_uri(ENV['MONGOHQ_URL'])
> @db = conn.db(uri.path.gsub(/^\//, ''))
> end
> end
>
> I am new to both MongoHQ and Sinatra so I'm not sure what to do. Can
> you tell me if I am using settings correctly to see if I'm running on
> Heroku? Or am I missing something in the Mongo connection code?
>
> Thanks.
>
> -Ginny
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<heroku%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>
--
-Shane
--
You received this message because you are subscribed to the Google Groups
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/heroku?hl=en.