Auto eager loading broken for has_many through associations where the model is an STI subtype
Closed this issue · 3 comments
jturkel commented
Example models:
class Group < ActiveRecord::Base
has_many :users
has_many :articles, through: :users
end
class User < ActiveRecord::Base
belongs_to :group
has_many :articles
end
class Post < ActiveRecord::Base
belongs_to :user
end
class Article < Post
end
Can't auto eager load (or regular eager load) Group#articles
.
Underlying issue is rails/rails#11078. Workaround is to set auto_include = false
on these associations
jturkel commented
I've confirmed this is still an issue on Rails master.
sfcgeorge commented
I just tried Goldiloader and immediately had some issue involving the STI type field. However it seems to be fixed in Rails 5.2 (finally) and sure enough upgrading does seem to have fixed my issue :) rails/rails#14312
So, if anyone else experiencing STI issues with Goldiloader could upgrade to Rails 5.2 and confirm that the issue is fixed for them too, then I think this issue could be closed.