在我的ruby语法中的某处但我无法找到它

时间:2014-09-08 18:36:57

标签: javascript ruby sinatra cloud9-ide

我正在创建一个音乐播放器,根据Rcmmndr api的推荐从AWS S3中提取歌曲。该播放器是一个JavaScript播放器,但使用红宝石后端来获取歌曲。每次我进入具有播放器的页面时,我的服务器都会中止,我必须重新启动它们才能运行我的应用程序。这是我运行的ruby脚本:

songs = Database.check('songs').body #This pulls the list of songs from the database
user_id = Database.check("users/" + session[:user] + "/user_id").body #This pulls the user id

uri = URI.parse "http://api.rcmmndr.com/api_key/#{ENV['rcmmndr_api_key']}/recommend/#{user_id}"
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(Net::HTTP::Get.new(uri.request_uri))

#If there are no recommendations then the player randomly selects a song from the database
if response.body.to_s != "{}"
    song = JSON.parse(response.body).to_a.sample(1)[0][0]
    artist = Database.check("songs/" + song + "/artist").body
    title = Database.check("songs/" + song + "/title").body
else
    song = songs.to_a.sample(1)[0][0]
    artist = Database.check("songs/" + song + "/artist").body
    title = Database.check("songs/" + song + "/title").body
end

#The song's information is stored into JSON that is read by the javascript 
song_to_play = {}
song_to_play[:id] = song
song_to_play[:url] = "https://s3.amazonaws.com/bucket/#{song}"
song_to_play[:artist] = artist
song_to_play[:title] = title
song_to_play.to_json

我的终端吐出大约600条看起来像这样的线条以及许多其他线条,包括宝石的位置

7fc39e1a9000-7fc39e1ab000 rw-p 00000000 00:00 0 
7fc39e1ab000-7fc39e1ac000 r--p 00022000 00:2a3 35                        /lib/x86_64-linux-gnu/ld-2.19.so
7fc39e1ac000-7fc39e1ad000 rw-p 00023000 00:2a3 35                        /lib/x86_64-linux-gnu/ld-    2.19.so
7fc39e1ad000-7fc39e1ae000 rw-p 00000000 00:00 0 
7fffc29d2000-7fffc29f3000 rw-p 00000000 00:00 0                          [stack]
7fffc29fe000-7fffc2a00000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

以此结尾

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted

有人可以帮我找到原因吗?当我从我的应用程序中删除该代码时,它运行时音乐播放器不播放是唯一的问题。 (如果重要的话,我正在编写Cloud 9开发环境)

0 个答案:

没有答案