路由错误。 如何在rails中发布php文件

I am building a simple rails app, in which in an html, on window load, a php file is triggered.

The unload function on home.html.erb is:

window.onload = function() {
var request = new XMLHttpRequest();
request.open("POST", "generator.php, true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send("empty=1");}

This should simply call the php file, right?

generator.php should clean the contents of the justafile.txt

<?php
$txtFilename = 'justafile.txt';

if( isset( $_POST['empty'] ) && $_POST['empty'] == '1' ) {
    $txt = fopen($txtFilename, "r+");
    ftruncate($txt, 0);
    fclose($txt);
} ?>

I get the following error and I don't know why.

ActionController::RoutingError (No route matches [POST] "/generator.php")

I don't know if I should add something to the routes.rb file.

Rails.application.routes.draw do
  root 'static_pages#home'
  get 'static_pages/help'

Thanks in advance