2010-10-22 60 views

回答

2

在軌使用的ActiveResource,你做這樣的:

class PersonResource < ActiveResource::Base 
    self.site = "http://api.people.com:3000/" 
    self.proxy = "http://user:[email protected]:8080" 
end 

ryan = Person.new(:first => 'Ryan', :last => 'Daigle') 
# the next line posts this object serialized to xml to the configured url 
ryan.save    # => true 

http://api.rubyonrails.org/classes/ActiveResource/Base.html

如果您正在發佈到網站上有一個自定義的API(未激活的資源),你必須使用Net:HTTP