Я использую достаточно простую реализацию, основанную на этом примере: http://www.appelsiini.net/2010/using-bitly-with-httparty
Я положил этот файл в папку lib (bitly.rb)
require 'rubygems'
require 'httparty'
class Bitly
include HTTParty
base_uri "api.bit.ly"
@@login = "goldhat"
@@api_key = "R_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
def self.shorten(url)
response = get("/v3/shorten?login=#{@@login}&apiKey=#{@@api_key}&longUrl=#{url}")
response["data"]["url"]
end
end
По какой-то причине я получаю нулевой объект. Как будто горько даже не отвечает никакими данными. Я проверил это в своей консоли и в моем приложении и получил ту же ошибку:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
from c:/goldhat_production/lib/bitly.rb:9:in `shorten'
from (irb):1
Есть идеи?