{"action":"opened","issue":{"url":"https://api.github.com/repos/mongoid/mongoid/issues/3921","labels_url":"https://api.github.com/repos/mongoid/mongoid/issues/3921/labels{/name}","comments_url":"https://api.github.com/repos/mongoid/mongoid/issues/3921/comments","events_url":"https://api.github.com/repos/mongoid/mongoid/issues/3921/events","html_url":"https://github.com/mongoid/mongoid/issues/3921","id":54658941,"number":3921,"title":"MongoLab using underscore for username and database name in heroku","user":{"login":"donnykurnia","id":95402,"avatar_url":"https://avatars.githubusercontent.com/u/95402?v=3","gravatar_id":"","url":"https://api.github.com/users/donnykurnia","html_url":"https://github.com/donnykurnia","followers_url":"https://api.github.com/users/donnykurnia/followers","following_url":"https://api.github.com/users/donnykurnia/following{/other_user}","gists_url":"https://api.github.com/users/donnykurnia/gists{/gist_id}","starred_url":"https://api.github.com/users/donnykurnia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donnykurnia/subscriptions","organizations_url":"https://api.github.com/users/donnykurnia/orgs","repos_url":"https://api.github.com/users/donnykurnia/repos","events_url":"https://api.github.com/users/donnykurnia/events{/privacy}","received_events_url":"https://api.github.com/users/donnykurnia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-17T11:22:08Z","updated_at":"2015-01-17T11:22:08Z","closed_at":null,"body":"MongoLab that provide Mongo in Heroku set username and database name using underscore:\r\n\r\n    heroku config:get MONGOLAB_URI\r\n    mongodb://heroku_app33263013:7vuv9mai25mcb8c8ga4mrod3am@ds031611.mongolab.com:31611/heroku_app33263013\r\n\r\nI got this error when using mongoid-4.0.0:\r\n\r\n➜  bskriver git:(hotfix/fix_heroku_compile_error) ✗ heroku run rails c --app bskriver-c14\r\nRunning `rails c` attached to terminal... up, run.5702\r\nLoading production environment (Rails 4.0.5)\r\nirb(main):001:0> PageSetting\r\n=> PageSetting\r\nirb(main):002:0> PageSetting.count\r\nNoMethodError: undefined method `[]' for nil:NilClass\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/mongo_uri.rb:25:in `database'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/mongo_uri.rb:73:in `to_hash'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/factory.rb:106:in `parse'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/factory.rb:62:in `create_session'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/factory.rb:28:in `create'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions.rb:65:in `with_name'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions.rb:105:in `mongo_session'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions.rb:121:in `collection'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/sessions/options.rb:161:in `method_missing'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/contextual/mongo.rb:263:in `initialize'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/contextual.rb:53:in `new'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/contextual.rb:53:in `create_context'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/contextual.rb:35:in `context'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/contextual.rb:19:in `count'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/mongoid-4.0.0/lib/mongoid/findable.rb:51:in `count'\r\n        from (irb):2\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/commands/console.rb:90:in `start'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/commands/console.rb:9:in `start'\r\n        from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/commands.rb:62:in `<top (required)>'\r\n        from /app/bin/rails:4:in `require'\r\n        from /app/bin/rails:4:in `<main>'irb(main):003:0>\r\n\r\nI see that in file `lib/mongoid/sessions/mongo_uri.rb`, the username and dbname only expected to be word -, so the underscore in MONGOLAB_URI cause the errors above.\r\n\r\n"}}