我有几个 mongoid 模型:
class Album
include Mongoid::Document
field :name, type: String
embedded_in :band
end
class Band
include Mongoid::Document
field :name, type: String
embeds_many :albums
end
而且我正在尝试让inherited_resources将嵌入的专辑包含在乐队的json中,如下所示:
class BandsController < InheritedResources::Base
respond_to :html, :xml, :json
def permitted_params
params.permit!
end
protected
def collection
@bands ||= end_of_association_chain.includes(:albums)
end
end
但是在尝试检索波段列表时出现以下错误:
undefined method `eager_load' for Mongoid::Relations::Embedded::Many:Class
知道我可能做错了什么吗?