mongoid/mongoid — Issue #1472: Model.count is inconsistent
Author: mvj3
Created: 2011-12-02 09:19:39+00:00
State: open

I split a log collection into two collections, the original is named as rpt_verb_path_params(RptVerbPathParams as model name), and the new one is rpt_syncs(RptSync).

They are truely use the same database
irb(main):001:0> RptVerbPathParams.database == RptSync.database
=> true

But when i start a new rails console
[mvj3@lv current]$ bundle exec rails c
Loading production environment (Rails 3.0.10)
irb(main):001:0> RptSync.count
=> 0
irb(main):002:0> RptVerbPathParams.count
=> 4199681
irb(main):003:0> exit
[mvj3@lv current]$ mongo
MongoDB shell version: 1.8.3
connecting to: test
> use love_sa
switched to db love_sa
> db.rpt_syncs.count()
2317134
> db.rpt_verb_path_params.count()
4981030
>

The count is inconsistent, whatever rails console or mongo cmd. I think there is something wrong with mongoid.