has_many through: causes incorrect owner to be passed to the scope of the source association #13252

Closed
bughit opened this Issue Dec 10, 2013 · 4 comments

Comments

Projects
None yet
5 participants
Contributor

bughit commented Dec 10, 2013

the owner passed to the source is is the owner of has_many through: (Model1)

class Model2
  has_many :model3s, ->(owner) { }
end

class Model1
  has_one :model2
  has_many :model3s, through: model2
end
Member

senny commented Dec 10, 2013

@bughit please report Active Record issues with an attached executable test-case. This script can be used as foundation.

Contributor

kuldeepaggarwal commented Dec 18, 2013

@bughit Can you please provide more information?

This is just a fake example, but please have a look on this:

class Article < ActiveRecord::Base
  has_one :post
  has_many :comments, through: :post
end

class Post < ActiveRecord::Base
  has_many :comments, ->(owner) {  } # => here `owner` will be `post` object
end

class Comment < ActiveRecord::Base
  belongs_to :post
end

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 team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

bughit added the stale label May 27, 2014

rails-bot closed this Aug 19, 2014

This issue has been automatically closed because of inactivity.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment