Murtza
Murtza

Reputation: 1416

Mongoid throws error on saving record in rails console

I'm using rails 4.2.0.beta2 along mongoid 4.0.0 it works fine in browser but when i try it in rails console, i can instantiate objects but it doesn't save record instead it throws following error

Mongoid::Errors::NoSessionConfig:
Problem:
No configuration could be found for a session named 'default'.
Summary:
When attempting to create the new session, Mongoid could not find a session configuration for the name: 'default'. This is necessary in order to know the host, port, and options needed to connect.
Resolution:
Double check your mongoid.yml to make sure under the sessions key that a configuration exists for 'default'. If you have set the configuration programatically, ensure that 'default' exists in the configuration hash.
.......

mongoid.yml

development:
  sessions:
    default:
      database: okaab_development
      hosts:
        - localhost:27017
      options:
  options:
test:
  sessions:
    default:
      database: okaab_test
      hosts:
        - localhost:27017
      options:
        read: primary
        max_retries: 1
        retry_interval: 0

Upvotes: 1

Views: 205

Answers (1)

maxigs
maxigs

Reputation: 916

Just as info: This still is an issue with the current versions of Rails/Mongoid. The reason is related to spring, once deactivated it works fine.

Upvotes: 2

Related Questions