ActiveRecordは、デフォルトのJSON出力形式への変更を導入しました。それはから行きました
{ "user": { some_junk } }
に
{ some_junk }
ActiveResourceは明らかに彼らの先導に従い、JSONを次のように消費することを期待しています。
{ some_junk }
放出するRESTfulWebサービスを必死に消費しようとしています
{ "user": { some_junk } }
ActiveResource :: Baseクラスにそうするように指示する方法はありますか?これが私のコードです。
class User < ActiveResource::Base
self.site = "http://example.com/"
self.format = :json
end
更新:誰かが答えを知らない限り、私は今のところ壊れているとしてActiveResourceをあきらめています。その間に、私は自分が望んでいたGETを達成することができました
require '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!