此活动记录(2.3)查询是否正确且完整?

时间:2012-12-06 20:24:00

标签: ruby activerecord ruby-on-rails-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}])

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

0 个答案:

没有答案