Skip to content
  • eileencodes's avatar
    566c4033
    Fix disable_joins when foreign key is not ID · 566c4033
    eileencodes authored
    If you have a `has_one through` assocation where the `through` has a
    `belongs_to` the foreign key won't be `id` for the joins. This change
    ensures we use the correct foreign key when querying with disable joins
    turned off. Prior to this change the call to `project.lead_developer`
    would return `nil` if `disable_joins` was set.
    
    Project has one lead developer through firm. Project also belongs to
    firm. So when we call `project.lead_developer` it needs to find the
    lead developer through the firm. In these cases we don't want to read
    the owners id, we want to read the attribute that will give us the
    value of the first chain item's `join_foreign_key`.
    566c4033
    Fix disable_joins when foreign key is not ID
    eileencodes authored
    If you have a `has_one through` assocation where the `through` has a
    `belongs_to` the foreign key won't be `id` for the joins. This change
    ensures we use the correct foreign key when querying with disable joins
    turned off. Prior to this change the call to `project.lead_developer`
    would return `nil` if `disable_joins` was set.
    
    Project has one lead developer through firm. Project also belongs to
    firm. So when we call `project.lead_developer` it needs to find the
    lead developer through the firm. In these cases we don't want to read
    the owners id, we want to read the attribute that will give us the
    value of the first chain item's `join_foreign_key`.
Loading