无法从应用发布到服务器端的其他应用

时间:2013-01-23 06:28:52

标签: ruby-on-rails post routes

我的本​​地主机上有3000个应用程序在端口3000和9000(rails 2和sinatra app)上运行。 我在app/controllers/finance_service.rb

中的rails应用程序中设置了一个控制器(没有任何特定的模型或视图)
class FinanceServiceController < ApplicationController
    def after_token_create 
        p "after token create function: #{params.inspect}"
    end
end

并设置了这样的路线:

map.finance_service '/finance_service' , :controller => "finance_service", :action => "after_token_create"

当我在网址http://localhost:3000/finance_service

上访问它时

我在模板丢失时遇到错误,但这很好,因为这意味着路由正在运行(我将其用作另一个应用程序的服务API)。

尝试使用httparty gem从其他应用程序访问该方法时如此:

HTTParty.post("http://localhost:3000/FinanceServiceController/after_token_create", :body => post_params)

我在rails app-

上收到错误
myapp/public/404.html (method_not_allowed)

还尝试从高级Rest客户端应用程序,我得到相同的错误。

1 个答案:

答案 0 :(得分:0)

请求不应该是这样的吗?因为路由匹配器是/ finance_service

HTTParty.post("http://localhost:3000/finance_service", :body => post_params)