Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8894

Show
Ignore:
Timestamp:
02/18/08 04:49:56 (2 years ago)
Author:
nzkoz
Message:

Ensure nested preloading works when associations return nil. Closes #11145 [GMFlash]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8890 r8894  
    11*SVN* 
     2 
     3* Ensure association preloading doesn't break when an association returns nil. ##11145 [GMFlash] 
    24 
    35* Make dynamic finders respect the :include on HasManyThrough associations.  #10998. [cpytel] 
  • trunk/activerecord/lib/active_record/association_preload.rb

    r8762 r8894  
    2222            reflection = reflections[parent] 
    2323            parents = records.map {|record| record.send(reflection.name)}.flatten 
    24             unless parents.empty? 
     24            unless parents.empty? || parents.first.nil? 
    2525              parents.first.class.preload_associations(parents, child) 
    2626            end 
  • trunk/activerecord/test/cases/associations/eager_test.rb

    r8890 r8894  
    7575  def test_loading_with_no_associations 
    7676    assert_nil Post.find(posts(:authorless).id, :include => :author).author 
     77  end 
     78 
     79  def test_nested_loading_with_no_associations 
     80    assert_nothing_raised do 
     81      Post.find(posts(:authorless).id, :include => {:author => :author_addresss}) 
     82    end 
    7783  end 
    7884