2010-10-22 46 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