2
我有3個型號Report
,Server
和Platform
。我需要執行一個涉及三連接所有3個模型並基於此進行查詢的查詢。但是,當我嘗試三重連接時,出現以下錯誤:Rails Triple加入
ActiveRecord :: ConfigurationError:未找到名爲「platform」的關聯;也許你拼錯了嗎?
這裏是我的模型
報告
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
對不起,我有一些錯別字。你的回答是正確的。謝謝。 – user2158382
我想知道如何在連接字段的where子句中指定不等式? – Chloe