2

我有一些相关的模型(Rails 2):

class User < ActiveRecord::Base
  has_many :proposals, :dependent => :destroy  
end

class Proposal < ActiveRecord::Base
  belongs_to :user
  has_many :proposal_sections, :dependent => :destroy
end

class ProposalSection < ActiveRecord::Base
  belongs_to :proposal
end

在行动中,我想返回所有与用户数据相关的数据。我正在使用这个查询:

User.find(:first, :conditions => ["id = ?", params[:id]], :include => [:proposals,   {:proposals => :proposal_sections}])

此查询是否正确且完整?谢谢你的回答。

4

0 回答 0