Skip to content

Default scope includes(:association) is ignored #1233

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

2 participants

@pixeltrix
Ruby on Rails member

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.

@jonleighton jonleighton was assigned May 23, 2011
@jonleighton
Ruby on Rails member

Failing tests would be great, thanks! :)

@pixeltrix
Ruby on Rails 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.

@pixeltrix pixeltrix added a commit that referenced this issue May 24, 2011
@pixeltrix pixeltrix Failing tests for #1233. f1f1ab7
@jonleighton jonleighton added a commit that closed this issue May 24, 2011
@jonleighton jonleighton Ensure that the surrounding code in Relation#to_a respects the defaul…
…t_scope (as well as having Relation#arel respect the default scope). Fixes #1233.
a000ff7
@pixeltrix pixeltrix added a commit that referenced this issue May 24, 2011
@pixeltrix pixeltrix Failing tests for #1233. 0daf574
@joshk joshk pushed a commit that referenced this issue May 25, 2011
@jonleighton jonleighton Ensure that the surrounding code in Relation#to_a respects the defaul…
…t_scope (as well as having Relation#arel respect the default scope). Fixes #1233.
63a6598
@ttosch ttosch pushed a commit that referenced this issue Jan 19, 2015
@pixeltrix pixeltrix Failing tests for #1233. 980e5b1
@ttosch ttosch pushed a commit that referenced this issue Jan 19, 2015
@jonleighton jonleighton Ensure that the surrounding code in Relation#to_a respects the defaul…
…t_scope (as well as having Relation#arel respect the default scope). Fixes #1233.
0cf4cb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.