我基本上想在下面提到的关联中添加一个条件
class Group < ActiveRecord::Base
has_one :post, :as => :owner, :dependent => :destroy
belongs_to :head_post, :class_name => 'Post', :dependent => :destroy, :foreign_key => 'head_post_id'
end
在帖子表中,我有两个记录,每个组是post和head_post,我使用组中的字段来区分这两个记录&#39; head_post_id&#39;
像
这样的东西 has_one :post, :as => :owner, :dependent => :destroy, :conditions => "posts.owner_id != #{self.head_post_id}"
但这似乎不起作用