EugZol / where_exists

Adds the power of SQL Exists to ActiveRecord
MIT License
110 stars 18 forks source link

More of a question/suggestion #9

Closed jhwinters closed 6 years ago

jhwinters commented 6 years ago

Really like the look of this, especially the ability to pass additional arguments to limit the selection of the other records.

However, as soon as I find myself putting a couple of additional arguments there I start feeling they should go in a scope in the target model, rather than the parent model having hard-coded details of the fields within the target.

Would it be silly to provide the means for passing the name of a scope as this second (or additional) argument? Quite happy to look at the implementation myself if it isn't a stupid idea.

John

SampsonCrowley commented 6 years ago

Interesting idea, I support it

EugZol commented 6 years ago
User.where_exists(:groups, &:approved)

After PR from @apauly you can do it like that. README is updated.