The eager loading on Ruby on Rails is not working properly for the following scenario.
First we had a model called marks which has the following fields
id, student, subject, mark
the student is a string column which has the active directory login value, later on for reporting functionality we introduce another table called user which has the following fields
id, ad_name, full_name
Now on the Mark model, we have added the belongs to class
belongs_to :student_details, :class_name = "User", :foreign_key = "student", :primary_key = "ad_name"
and when loading using the ActiveRecord's find method we are passing in the include conditon for eager loading
Marks.find(:all, :include = :reserved_user)
but when the find is executed, for each and every mark a student select query executed.
Is this a known bug in ROR? or am i missing something?