This is hard to read. Especially the 3-times-repeated `#{quoted_type[1..-2]}_system_entities`. I'd suggest:

1. change the second param to `alias`, and let it be an unquoted value. Do the quoting logic here instead of relying on the caller to do it.
2. or, if you don't do that, extract `#{quoted_type[1..-2]}_system_entities` into a variable

Also, the rails [guide](http://guides.rubyonrails.org/active_record_querying.html) suggests using class methods instead of scopes if parameters are required. Is there a good reason to not do that here?