Technically, you can by writing JS code which executes the ruby file as a script by first using shell, and given the computer has ruby installed you can simply run something like this:
var w = new ActiveXObject("WScript.Shell");
w.run('ruby Scripts\test.rb');
This is however not a good way to do it as you don't get any response or error messages from the executed file, it might cause some security issues and you're executing business logic in the frontend, which is always bad.
The correct way to do it is to make the ajax call to a endpoint, where you can control the access to the information, set business logic in the backend and give proper response. I'm not sure if you're using rails, but if you're you should just create a new path in routes.rb and create a controller method for it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…