ブログアプリで、記事付きのタグのリストを表示したい。
class Article < AR::B
has_and_belongs_to_many :tags
end
class Tag < AR::B
has_and_belongs_to_many :articles
end
タグスコープはどのようになりますか?
Tag.joins(:articles) ... # should return tags associated to at least 1 article
ブログアプリで、記事付きのタグのリストを表示したい。
class Article < AR::B
has_and_belongs_to_many :tags
end
class Tag < AR::B
has_and_belongs_to_many :articles
end
タグスコープはどのようになりますか?
Tag.joins(:articles) ... # should return tags associated to at least 1 article