-1
我已經連接好了一切,它看起來很棒。但是我在代碼中缺少一些東西,因爲我無法從返回的Hash
中獲取值。這主要是在軌道上使用考拉Facebook的寶石。從軌道中散列收集變量
到目前爲止我有:
def self.pull
facebook = user.facebook.get_connection("me", "home")
facebook.each do |story| # Each story is itself a Hash
unless exists?(fb_id: story.id)
NewStory.create({fb_id: story.id, fb_from_username: story.from.username, user_id: User.current, storystatus = 'new'})
end
end
end
運行pull
我不斷收到錯誤undefined method 'id' for #<Hash:0x007fc8f2784278>
...我知道它Hash
但我從來沒有嘗試訪問的Hash
內容,返回哈希的示例如下所示:
{
"id"=>"650490971730768_650591128387419",
"from"=>{
"id"=>"650490971730768",
"name"=>"Kathy Singer"
}
...
}
試圖從抓住id
然後我將移動到from -> id
和from -> user
等。
感謝抱歉愚蠢的問題訪問:) – user2419316 2014-10-01 14:20:49