Ruby on Rails ActiveRecord: problem with loadable download using foreign and primary key

The expected download of Ruby on Rails does not work properly for the following scenario.

First we had a model called mark, which has the following fields
id, student, subject, mark

the student is a string column with the active directory entry name, and later for reporting functions another table is introduced with the name user, which has the following fields:
id, ad_name, full_name

Now on the Mark model we have added class affiliation

belongs to_to: student_details ,: class_name => "User" :: foreign_key => "student" ,: primary_key => "ad_name"

and when loading using the ActiveRecord search method, we pass the included conditon for heavy loading

Marks.find (: all ,: include =>: reserved_user)

but when a search is performed, a student selection request is made for each marking.

Is this a known bug in ROR? or am I missing something?

+3
source share
1 answer

See ticket . There is a patch in the comments

0
source

Source: https://habr.com/ru/post/1743328/


All Articles