Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么我会得到';没有将字符串隐式转换为整数';在轨_Ruby On Rails_Ruby - Fatal编程技术网

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']
,就像您在该行的其他地方一样。

但是由于返回的数组不止一个,我如何在不使用每个数组的情况下对它们进行拆分,并在数据库中创建条目