0

嗨,我在我的 rails 应用程序 2.3.11 中使用acts_as_taggable。

我有模型用户,他可以发布具有关联标签的帖子。所以我使用喜欢

@tags = User.find(:first).posts.tag_counts

获取将使用 tag_cloud 显示的标签

现在的问题是,我们有一些功能可以根据帖子类型的某些条件删除用户的一些帖子,现在我如何才能只获取这些帖子的标签。我想要的帖子保留在 @posts 中。但是如何使用相同的..

请给一些建议

4

1 回答 1

0

在帖子中定义一个范围,该范围根据帖子类型定义条件。因为,你没有提到确切的标准..

class Post < ActiveRecord::Base
  scope :specific_type, <?> #fill in with conditions for type of post
end

User.find(:first).posts.specific_type.tag_counts
于 2011-08-09T12:44:05.110 回答