Ruby on Rails Instagram Gem like和评论计数不正常

我试图循环浏览Instagram返回的数据并在网页上显示信息。 我可以从字面上得到每个字段的工作除了类似或评论计数。 出于某种原因,它总是返回所有字段的相同数字(2),即使我查看返回的JSON,计数明显不同。 其他一切都正常应用。

更具体地说,我使用Ruby on Rails Instagram Gem,使用tag_recent_media(用户)方法获取数据。

def index result = [] next_id = nil while result.length  params[:page], :per_page => 30) end 

在我的html.erb中:

  instagram.images.standard_resolution.url //gives me image url correctly instagram.caption.text //gives me caption text correctly instagram.user.username //gives me the username correctly instagram.likes.count //always gives me 2! instagram.comments.count //always gives me 2!  

任何人都知道可能会发生什么?

这是Instagram Ruby Gem行为中记录的错误 , 可能源于保留count

建议使用嵌套哈希表示法而不是点表示法来解决该问题:

 instagram.likes[:count] instagram.comments[:count] 

做一个puts instagram.likesputs instagram.comments 。 我敢打赌,喜欢和评论会返回一个数组或哈希值,你需要更深一层来获得实际数量。