Report
、Server
、および の3 つのモデルがありPlatform
ます。3 つのモデルすべてをトリプル結合し、それに基づいてクエリを作成するクエリを実行する必要があります。しかし、トリプル結合しようとすると、次のエラーが発生します
ActiveRecord::ConfigurationError: 「プラットフォーム」という名前の関連付けが見つかりませんでした。おそらくあなたはそれを書き間違えましたか?
ここに私のモデルがあります
報告
class Report < ActiveRecord::Base
belongs_to :server
delegate :company_id, :to => :server
class << self
def method(url, base_url)
Report.joins(:server).joins(:platform).where(:platforms => {:company_id => 5}).all
end
end
end
サーバ
class Server < ActiveRecord::Base
has_many :reports
belongs_to :platform
end
プラットホーム
class Platform < ActiveRecord::Base
attr_accessible :company_id
has_many :servers
end