0
我想获取子节点引用的对象,因此我可以进行查询。在rabl中访问儿童“当前”对象
我的代码如下所示:
child @course_types => :course_types do |course_type|
attributes :id, :name, :deleted
child CourseTypeCategory.where(course_type: course_type, active: true) => :category_position do
attributes :category_id, :position
end
end
此查询CourseTypeCategory.where(course_type: course_type, active: true)
总是返回相同的结果,如果course_type
总是相同的各类型它就会出现(在这种情况下,我怀疑的结果总是@course_types的第一个对象)。有没有办法让孩子的“当前对象”,并作出查询,如果你正在做一个循环(如each do
)?
如果问题很混乱,请提前致谢。
工作感谢 – InesM