Use render :plain if you want the Rails controller to return plain text.
From Prem in https://github.com/rails/rails/issues/12374:
render :textmisdirect people to think that it would render content with
text/plainMIME type. However,
render :textactually sets the response body directly, and inherits the default response MIME type, which is