2

I had create two environment for development on local machine and staging on heroku.

Here my 'mongoid.yml':

development:
  sessions:
    default:
      database: mydb_development
      hosts:
        - localhost:27017
staging:
  sessions:
    default:
      database: mydb_staging
      uri: <%= ENV['MONGOLAB_URI'] %>

Mongoid works properly on local machine, but after heroku deployment I take next error:

/app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.14/lib/mongoid/config/validators/session.rb:81:in `validate_session_uri':  (Mongoid::Errors::MixedSessionConfiguration)
2012-12-25T10:12:44+00:00 app[web.1]: Problem:
2012-12-25T10:12:44+00:00 app[web.1]:   Both uri and standard configuration options defined for session: 'default'.
2012-12-25T10:12:44+00:00 app[web.1]: Summary:
2012-12-25T10:12:44+00:00 app[web.1]:   Instead of simply giving uri or standard options a preference order, Mongoid assumes that you have made a mistake in your configuration and requires that you provide one or the other, but not both. The options that were provided were: {"database"=>"xxxxx_staging", "uri"=>"mongodb://xxxxx:xxxxx@xxxxx.mongolab.com:37587/xxxxxx"}.
2012-12-25T10:12:44+00:00 app[web.1]: Resolution:
2012-12-25T10:12:44+00:00 app[web.1]:   Provide either only a uri as configuration or only standard options.

What phrase 'Provide either only a uri as configuration or only standard options' means? How to configure mongoid for development and staging properly?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Denis Kreshikhin
  • 8,856
  • 9
  • 52
  • 84

1 Answers1

7

Remove this line:

database: mydb_staging

as the database name is present in the URI.

Dogbert
  • 212,659
  • 41
  • 396
  • 397