This project is archived and is in readonly mode.
Nested finder include option with has_one
Reported by Akshay Rawat | March 25th, 2009 @ 05:46 PM | in 3.x
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
Comments and changes to this ticket
-
Akshay Rawat March 25th, 2009 @ 05:50 PM
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
-
Akshay Rawat March 29th, 2009 @ 06:08 PM
- Assigned user set to Frederick Cheung
Assigning it to Frederick
-
Santiago Pastorino February 2nd, 2011 @ 04:40 PM
- 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.
-
Santiago Pastorino February 2nd, 2011 @ 04:40 PM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>