Does not look like the right thing to put on a scope.
Maybe you are trying to accomplish this:
class PostTag < ...
belong_to :post
belongs_to :tag
def distincttag
find(:all, :select => 'distinct tag_id')
end
end
Edit: now that I know what you need:
User
has_many :posts
has_many :post_tags, :through => :posts, :select => 'distinct tags.*'
# or, if you are not worried about database overhead:
has_many :post_tags, :through => :posts, :uniq => true
Reference: http://blog.hasmanythrough.com/2006/5/6/through-gets-uniq
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…