Question

I was using acts_as_audited in my Rails 2 app and am in the process of updating it to Rails 3. I have updated a couple of models to call audited instead of acts_as_audited and those seem to work successfully. However, I am updating the User model of my app now and when I try to create a User (either from the console or from the app), I get the following error:

uninitialized constant User::Audit

The trace down the where it seems relevant is:

activerecord (3.2.8) lib/active_record/inheritance.rb:111:in `compute_type'
activerecord (3.2.8) lib/active_record/reflection.rb:172:in `klass'
activerecord (3.2.8) lib/active_record/associations/collection_association.rb:148:in `transaction'
activerecord (3.2.8) lib/active_record/associations/collection_association.rb:431:in `create_record'
activerecord (3.2.8) lib/active_record/associations/collection_association.rb:119:in `create'
activerecord (3.2.8) lib/active_record/associations/collection_proxy.rb:46:in `create'
audited (3.0.0) lib/audited/auditor.rb:216:in `block in write_audit'
activesupport (3.2.8) lib/active_support/callbacks.rb:403:in `_run__3460157709255055264__audit__3867610640799995319__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_audit_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
audited (3.0.0) lib/audited/auditor.rb:216:in `write_audit'
audited (3.0.0) lib/audited/auditor.rb:198:in `audit_create'

The line that creates the issue in my controller simply states:

if @editing_user.save

I've looked through the support list of audited's github account and can't find anything that fits my issue. I thought I'd ask here to see if someone has had a similar issue. I've also searched here and google to find an answer to this specific question but can't find anything relevant.

Any ideas?

Was it helpful?

Solution

It turns out that I had has_many :audits within the User model but not any other model. After I removed that has_many call, everything worked fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top