Ruby on rails 包括与条件的关联

Ruby on rails 包括与条件的关联,ruby-on-rails,activerecord,associations,Ruby On Rails,Activerecord,Associations,我试图把这个协会包括在内 class Moment < ActiveRecord::Base has_many :user_taggings_excluded_creator, class_name: "UserTagging", conditions: proc {["user_id != ?", self.created_by]} Edit:似乎self不是我的类Moment,而是调用此关联的类 我不知道发生了什么事。有人有吗 提前感谢。错误告诉您,由创建的属性不存在于类用户标记的

我试图把这个协会包括在内

class Moment < ActiveRecord::Base

has_many :user_taggings_excluded_creator, class_name: "UserTagging", conditions: proc {["user_id != ?", self.created_by]}
Edit:似乎
self
不是我的类
Moment
,而是调用此关联的类

我不知道发生了什么事。有人有吗


提前感谢。

错误告诉您,由创建的属性
不存在于类
用户标记的实例上


查看您的
db/schema.rb
文件,检查该属性是否存在。

这似乎很奇怪,因为
self
引用了另一个类。我不明白为什么它在控制台上工作,但当我从
includes
调用它时却不工作。我刚刚更新了代码,以显示哪个类是
self
NoMethodError - undefined method `created_by' for #<ActiveRecord::Relation::ActiveRecord_Relation_UserTagging:0x0000010548b920>: