0
我試圖使用Twitter的寶石在Rails 3應用程序,但不斷收到以下錯誤:Twitter的寶石和Rails的3 - 類型錯誤:不能轉換成路徑名字符串
TypeError: can't convert Pathname into String
這裏是我的代碼「M試圖運行:
class Tweet < ActiveRecord::Base
def self.test_tweet
Twitter.user_timeline("sferik").first.text
end
end
以下是完整的錯誤消息:
類型錯誤:不能轉換成路徑名字符串
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `initialize'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `new'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:658:in `connect'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:626:in `start'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from /home/shane/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:888:in `get'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/adapter/net_http.rb:59:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/request/url_encoded.rb:14:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/request/multipart.rb:13:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter/request/multipart_with_file.rb:17:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter/request/phoenix.rb:13:in `call'
from /home/shane/.rvm/gems/[email protected]/gems/faraday-0.7.6/lib/faraday/connection.rb:210:in `run_request'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter/request.rb:23:in `request'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter/request.rb:11:in `get'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter/client/timelines.rb:208:in `user_timeline'
from /home/shane/.rvm/gems/[email protected]/gems/twitter-2.1.1/lib/twitter.rb:17:in `method_missing'
from /home/shane/projects/bv_data/app/models/tweet.rb:5:in `test_tweet'
from (irb):1
from /home/shane/.rvm/gems/[email protected]/gems/railties-3.1.2/lib/rails/commands/console.rb:45:in `start'
from /home/shane/.rvm/gems/[email protected]/gems/railties-3.1.2/lib/rails/commands/console.rb:8:in `start'
from /home/shane/.rvm/gems/[email protected]/gems/railties-3.1.2/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我跑從控制檯相同的代碼時出現此錯誤甚至:
Twitter.user_timeline("sferik").first.text
我創建了一個空白的測試應用程序使用相同版本的軌道和嘰嘰喳喳的寶石,它運行沒有問題,所以我我不確定問題是什麼。
包安裝? – 2012-03-22 23:29:05
不幸的是,捆綁安裝或捆綁包更新不能解決問題 – shane 2012-03-23 16:50:27
這只是一個想法,每當我得到一個非常奇怪的錯誤,它通常會證明我沒有遷移,捆綁安裝或重新啓動服務器/控制檯/ spork :)。 – 2012-03-23 18:18:11