Skip to content

Turn Group#owners into a has_many association

yorickpeterse-staging requested to merge group-owners-association into master

What does this MR do?

This turns the regular method Group#owners into a has_many association.

Are there points in the code the reviewer needs to double check?

As far as I can tell there's no way to do this without using an intermediate association, but perhaps I'm missing something. The reason an intermediate association is needed is because the supplied Proc is applied to the final association (the one returning users), this means that when using a single has_many you can't filter out any intermediate rows (e.g. group members).

Why was this MR needed?

This code being a regular method would prevent eager loading of the owners of a Group, turning it into a has_many association resolves this problem. This was discovered in !4410 (merged).

What are the relevant issue numbers?

None.

Does this MR meet the acceptance criteria?

Merge request reports