我正在尝试使用 Mongoid CounterCache 但它不起作用。
我试着用
belongs_to :user, counter_cache: true
但它返回
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.
所以我加了
include Mongoid::CounterCache
重新启动我的网络服务器,然后再次尝试,但它返回
uninitialized constant Mongoid::CounterCache
关于这个问题的任何想法?