spudtrooper/rdiorb — Issue #9: create_json (err): undefined method `each'
Author: johanoskarsson
Created: 2012-02-26 23:14:04+00:00
State: open

Hi.

I'm using this gem to create playlists on Rdio. It works fine, the playlist is created correctly, but it does throw an error.

This is the error and stacktrace. I've removed some keys in the json just in case.

create_json (err): undefined method `each' for "Johan Oskarsson":String
create_json (str): {"status": "ok", "result": {"key": "...", "ownerKey": "...", "name": "Playlistify", "url": "/people/skr/playlists/611945/Playlistify/", "ownerIcon": "user/no-user-image-square.jpg", "owner": "Johan Oskarsson", "lastUpdated": 1330325975.0, "shortUrl": "http://rd.io/x/QFrCL0oJOw", "length": 50, "baseIcon": "album/b/9/5/000000000014f59b/square-200.jpg", "ownerUrl": "/people/skr/", "embedUrl": "http://rd.io/e/QFrCL0oJOw", "type": "p", "icon": "http://m.rdio.com/_is/?aid=237792,147201,216482,153219,23076,80461,221456,220187,4443&w=200&h=200"}}
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:152:in `fill'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:171:in `block in fill'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:152:in `each'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:152:in `fill'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:321:in `fill_obj'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:373:in `_create_object'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:327:in `create_object'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/base.rb:309:in `return_object'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/api.rb:57:in `createPlaylist'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/rdio-0.0.96/lib/rdio/types.rb:356:in `create'
/Users/johan/Dev/playlistify/lib/targets/rdio_target.rb:19:in `add_tracks'

The code used is something like this
r_tracks = tracks.map { |track| Rdio::Track.search(track[:artist] + " " + track[:track],nil,['name']).first }
if (!r_tracks.empty?)
pl = Rdio::Playlist.create("Playlistify","Description...", r_tracks)
end