我正在将一个Rails应用程序升级到4.0版本。我收到了以下的弃用警告信息。我已经在Google上搜索过这个问题,但没有找到任何解释如何更改它的资料。
DEPRECATION WARNING: The :finder_sql association option is deprecated. Please find an alternative (such as using scopes)...
这里是导致警告的范围:
has_many :elective_instructors,
:class_name => "Instructor",
:finder_sql => proc { "SELECT DISTINCT people.* FROM people
INNER JOIN class_sections ON class_sections.instructor_id = people.id
INNER JOIN courses ON courses.id = class_sections.course_id
INNER JOIN taken_classes ON class_sections.id = taken_classes.class_section_id
WHERE
courses.core = FALSE
AND
taken_classes.student_id = #{id}
AND
people.type = 'Instructor'
AND
people.ignore = FALSE" }
非常感谢您的帮助和建议!如果您有任何好的想法,欢迎分享。谢谢!