Commit 37fe664d2601e2ad77a291ea4818e525e5e4b765
Exists in
master
and in
1 other branch
Merge pull request #42 from wegowise/mongolab
add support for Mongolab heroku addon
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
config/initializers/mongo.rb
1 | -if ENV['MONGOHQ_URL'] | ||
2 | - settings = URI.parse(ENV['MONGOHQ_URL'] || 'mongodb://localhost/sushi') | 1 | +if mongo = ENV['MONGOHQ_URL'] || ENV['MONGOLAB_URI'] |
2 | + settings = URI.parse(mongo) | ||
3 | database_name = settings.path.gsub(/^\//, '') | 3 | database_name = settings.path.gsub(/^\//, '') |
4 | 4 | ||
5 | Mongoid.configure do |config| | 5 | Mongoid.configure do |config| |
6 | config.master = Mongo::Connection.new(settings.host, settings.port).db(database_name) | 6 | config.master = Mongo::Connection.new(settings.host, settings.port).db(database_name) |
7 | config.master.authenticate(settings.user, settings.password) if settings.user | 7 | config.master.authenticate(settings.user, settings.password) if settings.user |
8 | end | 8 | end |
9 | -end | ||
10 | \ No newline at end of file | 9 | \ No newline at end of file |
10 | +end |