I'm trying to use Mongoid CounterCache but it doesn't work.
I tried to just use
belongs_to :user, counter_cache: true
But it returns
Problem:
Invalid option :counter_cache provided to relation :user.
Summary:
Mongoid checks the options that are passed to the relation macros to ensure that no ill side effects occur by letting something slip by.
Resolution:
Valid options are: autobuild, autosave, dependent, foreign_key, index, polymorphic, touch, class_name, extend, inverse_class_name, inverse_of, name, relation, validate, make sure these are the ones you are using.
So then I added
include Mongoid::CounterCache
Restarted my webserver then tried again, but it returns
uninitialized constant Mongoid::CounterCache
Any ideas about this problem?