Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def side_load_belongs_to
def side_load_has_many
has_association_relation do |options|
if join_table = @association.options[:through]
options.scope = options.scope.joins(join_table).distinct
options.scope = options.scope.joins(join_table).group "#{options.scope.table_name}.id"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately obvious (it wasn't to me anyway), but specifying the table name is necessary to avoid ambiguity with the joined table.

association_fk = @association.through_reflection.foreign_key.to_sym
options.filters = { join_table => { association_fk => model_ids } }
else
Expand Down