【发布时间】:2017-07-07 17:25:38
【问题描述】:
我在搞乱RSpotify,它是 Spotify API 的 ruby 包装器。
我添加了一个表单并发送了搜索结果参数以在 API 中查找,但我收到以下错误:
NoMethodError: undefined method `empty?' for nil:NilClass
from /Users/user/.rvm/gems/ruby-2.3.1/gems/rspotify-1.21.0/lib/rspotify/connection.rb:71:in `send_request'
我仔细检查并重新安装了 gem,将其添加到 gemfile 和所有内容中。我似乎无法弄清楚为什么它不起作用。
这是代码(几周前我写的时候它还在工作):
post '/music' do
search = RSpotify::Artist.search(params[:search])
@artist = search.first
@image = @artist.images.first["url"]
@top_tracks = @artist.top_tracks(:US)
albums = @artist.albums
@titles = []
albums.each { |album| @titles << album.name }
@titles.uniq!
@related_artists = @artist.related_artists
erb :'/music/show'
end
【问题讨论】:
-
github.com/guilhermesad/rspotify/issues/123- 这似乎是一个已知问题,有人已修复它,等待拉取请求。