Reputation: 5691
Below is the call trace...
NoMethodError - undefined method `each_pair' for :primary_preferred:Symbol:
bson (3.2.4) lib/bson/document.rb:82:in `initialize'
mongo (2.1.1) lib/mongo/client.rb:192:in `read_preference'
/Users/Sagar/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/forwardable.rb:183:in `read_preference'
mongo (2.1.1) lib/mongo/collection.rb:104:in `read_preference'
/Users/Sagar/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/forwardable.rb:183:in `read_preference'
mongo (2.1.1) lib/mongo/collection/view/readable.rb:411:in `default_read'
mongo (2.1.1) lib/mongo/collection/view/readable.rb:300:in `read'
mongo (2.1.1) lib/mongo/collection/view/iterable.rb:40:in `block in each'
mongo (2.1.1) lib/mongo/retryable.rb:46:in `read_with_retry'
mongo (2.1.1) lib/mongo/collection/view/iterable.rb:39:in `each'
mongoid (5.0.0) lib/mongoid/query_cache.rb:207:in `each'
mongoid (5.0.0) lib/mongoid/contextual/mongo.rb:240:in `block in first'
mongoid (5.0.0) lib/mongoid/contextual/mongo.rb:489:in `try_cache'
mongoid (5.0.0) lib/mongoid/contextual/mongo.rb:239:in `first'
mongoid (5.0.0) lib/mongoid/contextual.rb:20:in `first'
orm_adapter (0.5.0) lib/orm_adapter/adapters/mongoid.rb:22:in `get'
devise (3.4.1) lib/devise/models/authenticatable.rb:214:in `serialize_from_session'
devise (3.4.1) lib/devise.rb:467:in `block (2 levels) in configure_warden!'
warden (1.2.3) lib/warden/session_serializer.rb:34:in `fetch'
warden (1.2.3) lib/warden/proxy.rb:212:in `user'
warden (1.2.3) lib/warden/proxy.rb:318:in `_perform_authentication'
warden (1.2.3) lib/warden/proxy.rb:104:in `authenticate'
devise (3.4.1) lib/devise/controllers/helpers.rb:120:in `current_user'
devise (3.4.1) lib/devise/controllers/helpers.rb:116:in `user_signed_in?'
Everything was working perfectly fine with Mongoid 4.2 and as soon as upgraded Mongoid to 5.0.0 I found this one!
Could you please help me out with this one? Not a clue how to debug this. Thank you in advance.
Upvotes: 0
Views: 174
Reputation: 5691
Mongoid 5 seems to have somewhat different mongoid.yml
I had the following mongoid.yml
development:
clients:
default:
database: db-name
hosts:
- localhost:27017
options:
read: :primary_preferred
When I changed the value to read:
from :primary_preferred
to {mode: :primary_preferred}
as follows, it did the trick!
development:
clients:
default:
database: db-name
hosts:
- localhost:27017
options:
read:
mode: :primary_preferred
Upvotes: 1