twoixter/trackoid — Issue #13: undefined method `validated?' for #<Mongoid::Tracking::Tracker>
Author: JamesHarrison
Created: 2011-12-29 23:19:00+00:00
State: open

Hi,

Running into this issue when saving (without tracking anything, though doing some tracking work doesn't change anything) a model (specifically a User, Devise-backed). Can't figure it out. Rails 3.1.3, Mongoid is latest git, Ruby 1.9.3

Stack trace is this:

trackoid (0.3.7) lib/trackoid/tracker.rb:32:in `method_missing'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:36:in `block in validate_each'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:32:in `collect'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations/associated.rb:32:in `validate_each'
activemodel (3.1.3) lib/active_model/validator.rb:153:in `block in validate'
activemodel (3.1.3) lib/active_model/validator.rb:150:in `each'
activemodel (3.1.3) lib/active_model/validator.rb:150:in `validate'
activesupport (3.1.3) lib/active_support/callbacks.rb:302:in `_callback_before_168889'
activesupport (3.1.3) lib/active_support/callbacks.rb:495:in `_run_validate_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:43:in `block in run_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `call'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `run_cascading_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:42:in `run_callbacks'
activemodel (3.1.3) lib/active_model/validations.rb:212:in `run_validations!'
activemodel (3.1.3) lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
activesupport (3.1.3) lib/active_support/callbacks.rb:408:in `_run_validation_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:43:in `block in run_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `call'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:68:in `run_cascading_callbacks'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/callbacks.rb:42:in `run_callbacks'
activemodel (3.1.3) lib/active_model/validations/callbacks.rb:53:in `run_validations!'
activemodel (3.1.3) lib/active_model/validations.rb:179:in `valid?'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/validations.rb:70:in `valid?'
activemodel (3.1.3) lib/active_model/validations.rb:187:in `invalid?'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence/modification.rb:22:in `prepare'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence/operations/update.rb:43:in `persist'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence.rb:91:in `update'
/home/james/.bundler/ruby/1.9.1/mongoid-feb0a15a04a7/lib/mongoid/persistence.rb:156:in `upsert'
app/controllers/tags_controller.rb:82:in `unwatch'

The offending code setting this off is
`current_user.watched_tags -= [tag]
current_user.save`

Both tag and user are tracked objects (with multiple tracked fields - 4 in user, 2 in tag, but no name collisions across models), watched_tags is a has_many array with no inverse.

Any ideas what's causing this or how to go about debugging it?