【发布时间】:2011-10-15 04:19:56
【问题描述】:
我正在尝试从另一个 Rails 应用程序请求数据,但我不断收到“找不到 URL”错误。 是否可以使用调试器来确定预期的 ActiveResource 调用的预期 URL 和参数?
例如,我想使用以下参数发出 GET 请求:
https://some_server.com/employees/search.xml?last_name=smith
我有以下 ActiveResource 模型
class Employee < ActiveResource::Base
self.site = "https://some_server.com"
end
而 some_server.com 应用程序有一个搜索操作以这种方式映射:
map.connect "/employees/search.:format", :controller => 'employees', :action => 'search'
但是当我尝试这个时:
Employee.new(:last_name => 'smith).get(:search)
我收到 404“未找到服务”错误。对我来说,这听起来像 ACtiveResource 请求的 URL 不正确,因为当我通过浏览器发出上述请求时,我得到了 xml。知道我做错了什么吗?
欢呼, 伯恩斯
【问题讨论】:
-
你的登录服务器是什么?请求真的来电了。我想这不是你想的那样。
标签: ruby-on-rails web-services activerecord activeresource