ActiveRecord and postgres lateral joins

Hi,

Is there any way to use PostgreSQL LATERAL joins (PostgreSQL: Documentation: 9.3: Table Expressions) with AR#eager_load on associations, to achieve partial eager loading?

My situation is: I have 2 models groups and users link together with a has_many :trough models memberships. When I list the groups, I want to eager load only the membership of the current user if it exists. Using this postgres function is the best way I have come up with.

Any thoughts?