4
은 내가는 :
p = Project.find(1, :include => :comments)
p.comments.collect(&:user).collect(&:name) # this executes select for each user
가 어떻게 나는 또한 주석의 사용자를 포함 할 말을 할 할 수있는
class Project < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :project
belongs_to :user
end
class User < ActiveRecord::Base
has_many :comments
end
그래서이 모델을 말해봐 레일 액티브에 포함?
이미 재귀 적이 아닌 것을 이미 포함하고 있다면 어떻게해야합니까? 나는 현재 : include => : items를 가지고 있으므로 이와 같이 결합해야합니다 : include => {: other_item => : items}. 가능합니까? – Michael