我在我的Rails2应用程序中使用了acts_as_audited,并且正在将其更新到Rails3。我已经更新了几个模型来调用audited而不是acts_as_audited,这些模型似乎工作得很成功。然而,我现在正在更新我的应用程序的用户模型,当我尝试创建用户(从控制台或应用程序)时,我得到以下错误:
uninitialized constant User::Audit它看起来相关的地方是:
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'在我的控制器中创建问题的代码行简单地声明:
if @editing_user.save我已经查看了审计的github帐户的支持列表,但找不到任何适合我的问题。我想我应该在这里问一下,看看是否有人有类似的问题。我还在这里和谷歌上搜索了这个特定问题的答案,但找不到任何相关的东西。
有什么想法吗?
发布于 2012-10-12 23:48:25
事实证明,我在用户模型中使用了has_many :audits,但在其他模型中没有。在我删除了那个has_many调用之后,一切都很正常。
https://stackoverflow.com/questions/12787656
复制相似问题