【发布时间】:2009-05-05 20:06:03
【问题描述】:
ActiveRecord 对其默认的 JSON 输出格式进行了更改。它来自
{ "user": { some_junk } }
到
{ some_junk }
ActiveResource 显然已经跟随他们的脚步,期望将 JSON 用作
{ some_junk }
我正在拼命地使用一个 RESTful Web 服务,它发出
{ "user": { some_junk } }
有没有办法告诉我的 ActiveResource::Base 类这样做?这是我的代码。
class User < ActiveResource::Base
self.site = "http://example.com/"
self.format = :json
end
更新:除非有人知道答案,否则我现在放弃 ActiveResource 作为损坏;同时,我能够通过
实现我想要的 GETrequire 'httparty' # sudo gem install httparty
result = HTTParty.get('http://foo.com/bar.json', headers => { "Foo" => "Bar"})
# result is a hash created from the JSON -- sweet!
【问题讨论】:
标签: ruby json rest activeresource