私はモデル記事を持っています
class Article
include Mongoid::Document
has_and_belongs_to_many :categories, inverse_of: nil
end
そして私はモデルカテゴリを持っています
class Category
include Mongoid::Document
field :name, type: String
end
、などAuthor
の名前のカテゴリがいくつかあります。私はこれを試します:Security
Mobile
category.name == 'Author'
Article.where(categories: [name: 'Author'])
しかし、うまくいきません。