【发布时间】:2013-02-04 16:43:26
【问题描述】:
我正在尝试使用 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
对这个问题有什么想法吗?
【问题讨论】:
标签: ruby-on-rails mongoid counter-cache