Ruby .concat 错误:循环结束时出现 Nomethod 错误

问题描述 投票:0回答:0

我有一个用于处理 Sproutvideo::Video.lst() 请求中的分页的 Ruby 代码片段。 Sprout 视频响应采用 JSON 格式 AFAIK。该代码段产生此错误: NoMethodError - #Hash:0x00007fa5d0139930

的未定义方法“concat”

代码如下:

   # Perform operations for each page
   pages.times do |page|   
   # Update the page number in the request options
   options[:page] = page + 1
   resource2 = Sproutvideo.const_get(resource_name)
   response2 = resource2.list(options)
   resources2 = response2.body[:videos]
   my_resources += resources2 
   end

这是 Replit 链接: 这是 Replit 链接

我试过 .concat、push 和 current 方法。所有给出相同的结果。我已将 my_resources 输出到控制台,看起来它可以工作,然后它只是在最后一页之后(期间?)抛出错误。 我还与 ChatGPT 和 Ghostwriter 合作,试图找到解决方法。任何建议将不胜感激。

arrays ruby api replit
© www.soinside.com 2019 - 2024. All rights reserved.