1
2.1.0から2.3.10にアップグレードするだけのアプリがあります。アップグレード後、以前に機能していたアソシエーション拡張が失敗します。ここでは拡張のためのモデル上のコードは次のとおりです。Rails 2.3.10で連合拡張機能が動作しなくなった
Class Classroom
has_many :registrations
has_many :students, :through => :registrations, :uniq => true do
def in_group(a_group)
if a_driver
scoped(:conditions => ['registrations.group_id = ?', a_group])
else
in_no_group
end
end
def in_no_group
scoped(:conditions => 'registrations.group_id is null')
end
end
end
これは私の実際の問題の単純化したモデルですが、基本的に私は
classroom.students.in_group(honor_students)
もはやこれで、作品を行うことができるために使用しました次の出力:
classroom.students.in_group(honor_students)
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'registrations.group_id' in 'where clause': SELECT * FROM `students` WHERE (registrations.group_id = 1234)
私はちょうど学生のリストをつかむ、SQLはすべての期待している結合構文を上記のバージョンから欠落しているそこのthats:
SELECT DISTINCT `students`.* FROM `students` INNER JOIN `registrations` ON `students`.id = `registrations`.student_id WHERE ((`registrations`.classroom_id = 9876))
結合拡張にすべての結合SQLがないのはなぜですか?