Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Still a bug in association_preload.rb ?

#3146

if I specify my own primary key for belongs_to:

class Price < ActiveRecord::Base

 belongs_to article :primary_key => "produktnr"

end

and use a nested include:

class AllPrices
named_scope :all_record :include => [:price => :article] end

Preloading for article doesn't work sind the ids are taken for the select and not the given primary key.

I think there is a bug on line 324 of association_preload. I think it should honour the primary key given in the belongs_to statement.

Regards
Roger

Reported by rogergl · September 4th, 2009 @ 12:54 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. rogergl
    rogergl

    Changing line 324

    seems to make preloading work as expected:

    primary_key = options[:primary_key] || klass.primary_key

    At least I get as many (106 failures with JRuby) unit tests failures for the ActiveRecord test suite as before.

    Regards
    Roger

    September 4th, 2009 @ 08:16 PM

  2. Ryan Bigg
    Ryan Bigg
    • State changed from new to open

    Line 324 in where? Please provide more information.

    May 25th, 2010 @ 11:15 AM

  3. rogergl
    rogergl

    The error was in association_preload.rb but seems to be fixed in Rails 3.

    Regards
    Roger

    May 26th, 2010 @ 06:39 AM

  4. José Valim
    José Valim
    • State changed from open to resolved

    May 26th, 2010 @ 07:46 AM