[英]Nested Includes in Ruby on Rails 3
In Ruby on Rails I have School which has many children. 在Ruby on Rails中,我有一个有很多孩子的学校。 Children which has many activities.
儿童有很多活动。 And Activity which has one activity_types.
和Activity有一个activity_types。 I need help nesting includes.
我需要帮助嵌套包括。 In my Children Controller.
在我的儿童控制器。 I have this... which works.
我有这个...有效。
s = School.find(params[:school_id])
@school = s
@children = s.children.includes(:activities).all
But I want to also get the :activity_type from the activities from the children. 但我想从孩子们的活动中获取:activity_type。 I tried this
我试过这个
s = School.find(params[:school_id])
@school = s
@children = s.children.includes(:activities => :activity_types).all
But that did not work 但那没用
不要复活activity_type
。
s.children.includes(:activities => :activity_type).all
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.