I wonder if inner selects would be better here, e.g.
```
puppetclass.where(id host_classes.puppetclasses OR config_group_classes.puppetclass) 
```