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.

Nested finder include option with has_one

#2341

Looks like it is a problem only when there is a has_one relationship.

class Book < ActiveRecord::Base has_one :distributor end

class Distributor < ActiveRecord::Base belongs_to :book has_many :agents end

class Agent < ActiveRecord::Base belongs_to :distributor has_many :shops end

class Shop < ActiveRecord::Base belongs_to :agent end

Schema - http://pastie.org/426261

def test_should_load_avatars shop_1= Shop.create! shop_2= Shop.create! book= Book.create!(:distributor => Distributor.create!(:agents=> [Agent.create!(:shops => [shop_1, shop_2])]))

loaded_version = Book.find(book.id, :include => [:distributor => {:agents => :shops}], :order => 'shops.id')

assert(loaded_version.distributor.agents.first.shops.size == 2) #THIS ASSERTION FAILS WITH SHOPS.SIZE BEING 1, INSTEAD OF 2 end

This fails on Rails 2.2.2

Thanks, Akshay

Reported by Akshay Rawat · March 25th, 2009 @ 05:46 PM

State: stale
Milestone: 3.x
Assigned to: Frederick Cheung Frederick Cheung
Importance: none

Activity

  1. Akshay Rawat
    Akshay Rawat

    Nested finder usage with has_one relationship

    Code: http://pastie.org/426794

    This fails on Rails 2.2 and passes on Rails 2.0

    Thanks

    March 25th, 2009 @ 05:50 PM

  2. Akshay Rawat
  3. Akshay Rawat
    Akshay Rawat

    This problem exists in Rails 2.3.2 too.

    March 25th, 2009 @ 10:44 PM

  4. Akshay Rawat
  5. Akshay Rawat
    Akshay Rawat
    • Assigned user set to Frederick Cheung

    Assigning it to Frederick

    March 29th, 2009 @ 06:08 PM

  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:40 PM

  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:40 PM