first off, the ruby code embedded in the template is parsed on the
server. the results are then sent to the browser/client with the
appropriate headers (html, xml, etc). so your call to 'system' is
being processed on the server, the results of which , if any,
incorporated into the response which is then sent to the browser.
You seem to have missed it the first times it was mentioned, but your code will cause the questions to be spoken on the server. That is not on the local machine of the user. For the user to hear the stuff that's spoken, they'd have to get up and walk to the server room. Probably not what you're looking for.
Has a decent enough into into doing ajax calls with rails. But, I'm
kind of curious about something kind of fundamental here, you're using
a system command on the server to speak the text? Is the user ALWAYS
sitting at the server, or within earshot of it's speakers? Otherwise,
I don't think you'll be getting what you intended, and the solution to
speaking dynamic text to the user from a web-page will be
significantly more complicated than executing osascript.
Elegant is all up to the beholder, I think a lot of rube goldberg
machines are very elegant. But I would have a lot of fun stealing
your passwords by hitting your webserver with my machine configured
with a promiscuous ssh server. Not to mention watching you squirm as
your hairs turn grey while you troubleshoot your ssh connectivity for
the next [insert how long you think you will work at your current job
here] years.