Ruby on rails 为什么我会得到';没有将字符串隐式转换为整数';在轨
当我尝试运行我的模型和下面的程序时,我总是得到“没有将字符串隐式转换为整数”的结果Ruby on rails 为什么我会得到';没有将字符串隐式转换为整数';在轨,ruby-on-rails,ruby,Ruby On Rails,Ruby,当我尝试运行我的模型和下面的程序时,我总是得到“没有将字符串隐式转换为整数”的结果 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.f
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
如果我在控制台中执行此操作,它可以正常工作,但我需要执行。每个都执行|故事|
fbstory = User.current.facebook.get_connection("me", "home").first
fbstory["shares"]["count"]
story
是一个数组,需要用数字索引。您有故事[“创建时间”]
。不能使用字符串为数组编制索引。您需要使用story.first['created_time']
,就像您在该行的其他地方一样。但是由于返回的数组不止一个,我如何在不使用每个数组的情况下对它们进行拆分,并在数据库中创建条目