0

在 js 文件中:

function jqShowResourcesSelection( elem, select_id )
{
    if (elem.checked){
        $("#" + select_id).attr("disabled","disabled");
        $.ajax({
            url: '/testbeds/resources_selection',
            type: 'POST',
            dataType : 'script',
            data: {"configuration_id": $("#" + select_id).val()},
            success: function() {
                addFilter();
            }
        });
    }
    else {
        $("#testbed_configuration_id").attr("disabled", false);
        $("#ResourcesSelection").html('');
    }
}

在路线.rb

ResourceManager::Application.routes.draw do
  resources :testbeds do
    collection do
      post :resources_selection
    end
  end
  resources :resources
  resources :configurations

  ...................

  root :to => 'configurations#index'

end

它在我的本地机器上运行良好,无论是开发环境还是生产环境。但是在服务器nginx中,触发js函数后,chrome控制台会显示:

POST http://example.com/testbeds/resources_selection 404 (Not Found)

我还尝试了“post”来“get”:

function jqShowResourcesSelection( elem, select_id )
{
    if (elem.checked){
        $("#" + select_id).attr("disabled","disabled");
        $.ajax({
            url: '/testbeds/resources_selection.js',
            type: 'GET',
            data: {"configuration_id": $("#" + select_id).val()},
            success: function() {
                addFilter();
            }
        });
    }
    else {
        $("#testbed_configuration_id").attr("disabled", false);
        $("#ResourcesSelection").html('');
    }
}

路线.rb:

ResourceManager::Application.routes.draw do
  resources :testbeds do
    collection do
      get :resources_selection
    end
  end
 ...........................

end

无论是开发环境还是生产环境,它在本地也能正常工作。但是在我选中复选框后,服务器中仍然是 404。

和 ngnix 配置如下:

http {
    passenger_root /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.18;
    passenger_ruby /usr/local/bin/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80;
        server_name cth-infra-07.datadomain.com 10.110.131.4 localhost;
        root /var/www/webapps/;
        rack_env production;
        passenger_enabled on;
        passenger_base_uri /resource_manager;
        passenger_base_uri /request_handler;
        passenger_base_uri /scheduler;
        passenger_base_uri /resque;
        passenger_base_uri /central_server;
    }

有人可以帮我吗?谢谢。

4

0 回答 0