After upgrade to Rails 3.0.10 I'm getting strange error if I set config.cache_classes=true
NoMethodError (undefined method
increment_counter' for ActiveRecord::Relation:Class):
activerecord (3.0.10) lib/active_record/associations.rb:1553:in
bel开发者_StackOverflowongs_to_counter_cache_after_create_for_form'
activesupport (3.0.10) lib/active_support/callbacks.rb:424:in _run_create_callbacks'
activerecord (3.0.10) lib/active_record/callbacks.rb:277:in
create'
activerecord (3.0.10) lib/active_record/persistence.rb:257:in create_or_update'
activerecord (3.0.10) lib/active_record/callbacks.rb:273:in
create_or_update'
activesupport (3.0.10) lib/active_support/callbacks.rb:444:in _run_save_callbacks'
activerecord (3.0.10) lib/active_record/callbacks.rb:273:in
create_or_update'
activerecord (3.0.10) lib/active_record/persistence.rb:60:in save!'
activerecord (3.0.10) lib/active_record/validations.rb:49:in
save!'
activerecord (3.0.10) lib/active_record/attribute_methods/dirty.rb:30:in `save!'
...
I'm saving Answer model which has belongs_to relation with counter cache:
belongs_to :form, :counter_cache => true
Strangest thing is that after server restart first save works fine and after that I start getting such exceptions.
Maybe someone could advise where I could start digging for a cause?
The problem was caused by outdated acts_as_taggable_on_steroids gem which was causing class cache issues with Rails3. Switched to acts-as-taggable-on gem - problem solved.
精彩评论