Default scope includes(:association) is ignored #1233

Closed
pixeltrix opened this Issue May 23, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@pixeltrix
Member

pixeltrix commented May 23, 2011

Given the following models:

class Menu < ActiveRecord::Base
  has_many :links, :as => :owner
  default_scope includes(:links)
end

class Link < ActiveRecord::Base
  belongs_to :menu, :polymorphic => true
end

then doing a Menu.first doesn't load the links. Pretty sure this is a regression from 3.0.x. There's a related issue with has_many :through as well where it tries to execute the default scope but can't find the association reflection. I'll add some more details later and provide some failing tests.

@ghost ghost assigned jonleighton May 23, 2011

@jonleighton

This comment has been minimized.

Show comment
Hide comment
@jonleighton

jonleighton May 23, 2011

Member

Failing tests would be great, thanks! :)

Member

jonleighton commented May 23, 2011

Failing tests would be great, thanks! :)

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix May 24, 2011

Member

@jonleighton I've created a pull request #1246 that seems to fix the issue - not sure if there's a better way of fixing it. The issue with has_many :through is different so I'll create a new ticket for that.

Member

pixeltrix commented May 24, 2011

@jonleighton I've created a pull request #1246 that seems to fix the issue - not sure if there's a better way of fixing it. The issue with has_many :through is different so I'll create a new ticket for that.

pixeltrix added a commit that referenced this issue May 24, 2011

pixeltrix added a commit that referenced this issue May 24, 2011

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