Steve Martocci's tumblr about programming, music, nyc, and start-ups

Using Mongoid on Heroku with MongoHQ

Heroku just announced a new MongoHQ addon which is totally awesome.  MongoHQ + Heroku is by far the fastest way to get a MongoDB backed application up and running on the web (for free non the less).  

Heroku’s docs have instructions for setting up the addon with MongoMapper but not with Mongoid (my current Mongo ORM of choice). I didn’t see an easy way to configure Mongoid from a url, so I added this to my application.rb file before the require ‘rails/all’ line. (For rails 2.x users, you can put this in a preninitializer.rb file in your config directory.  This works with the default mongoid.yml config file generated by Mongoid.

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(“/”, “”)
end

Maybe configuration via url will get added to the Mongoid Gem or the addon will support config via these variables but until then this is a nice and quick solution to get up and running.

Lol, Boxee remote on the iPad. It’s so huge! But at least now I can acutally pause a show when someone calls…

Watching the @disco_biscuits “On Time” music video via the MTV app on Boxee. Dropping cable by the end of the year may be a reality.

Really enjoying #GiltHackDay (24 hours of programming on whatever we want for @GiltGroupe). I’m working on a fun project with a great team

It’s different,but it’s still the same: check out @Skibeatz remix of @disco_biscuits “You And I” feat. @tabibonney http://bit.ly/a5z0fO

Hey @joshknowles, @brynary, @jrallison, you better have a bottle of Johnny Walker Blue Label with you when you finally show up.

Just watched the first 2 episodes of a SciFi miniseries I downloaded 3 years ago “The Lost Room”. Love it, can’t believe I waited so long

Zeus is a commercial load balencer/traffic manager we use at Gilt. @brynary and I built a test suite using his rack-test gem and rack-client

Great day building our RSpec test suite for #Zeus (@ZeusTechnology). Now that it’s maintainable let’s hope it doesn’t Release the Kraken!

Looks like the @disco_biscuits picked up a new fan. RT: @adamlambert Listening to Loose Change by the Disco Biscuits. Great band!