I am trying to get account information from Unfuddle API using ActiveResource
Url http://mydomain.unfuddle.com/api/v1/account
this is my ActiveResource class
class Account < ActiveResource::Base self.collection_name = "account" self.site = "https://mydomain.unfuddle.com/api/v1" self.user = "me" self.password = "pass" end
if I try to get account information with Account.all, I will get an empty array, but if I try this
require 'net/https' UNFUDDLE_SETTINGS = { :subdomain => 'mydomain', :username => 'me', :password => 'pass', :ssl => true } http = Net::HTTP.new("#{UNFUDDLE_SETTINGS[:subdomain]}.unfuddle.com",UNFUDDLE_SETTINGS[:ssl] ? 443 : 80) if UNFUDDLE_SETTINGS[:ssl] http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end begin request = Net::HTTP::Get.new('/api/v1/account') request.basic_auth UNFUDDLE_SETTINGS[:username], UNFUDDLE_SETTINGS[:password] response = http.request(request) if response.code == "200" puts response.body else puts "HTTP Status Code: #{response.code}." end rescue => e puts e.message end
I get information about my account, any ideas why the ActiveResource approach is not working?
** UPDATE
I forgot to point out that I had this problem https://github.com/rails/rails/issues/2318 and I am using erikkallens hack.
lesce source share