Reputation: 331
I keep getting 'no implicit conversion of String into Integer' when trying to run my model and the following;
def self.pull
fbstory = User.current.facebook.get_connection("me", "home")
fbstory.each do |story|
unless exists?(fb_id: story["id"])
User.current.new_fbtimeline_stories.create({fb_shares: story.first["shares"]["count"], fb_creation: story["created_time"], fb_message: story["message"], fb_status_type: 'new' })
end
end
end
and if I do this in the console it works fine but I need to do .each do |story|
fbstory = User.current.facebook.get_connection("me", "home").first
fbstory["shares"]["count"]
Upvotes: 0
Views: 781
Reputation: 239541
story
is an array, and needs to be indexed numerically. You have story["created_time"]
. You can't index arrays with strings. You need to use story.first['created_time']
as you have elsewhere on that line.
Upvotes: 1