A nice feature of ag is the ability to limit the search to a certain file type. E.g. to only search ruby files: ag --ruby foo.
To see a list of supported types and the matching file extensions: ag --list-file-types.
Just checked and rg does have something similar, but you need to specify the type as an argument to a flag: rg --type ruby foo.