Do not fail when file has no game data

master
Guillaume Dott 2014-12-11 12:18:04 +01:00
parent 717209a7f1
commit edaf64ea5c
1 changed files with 2 additions and 1 deletions

View File

@ -35,5 +35,6 @@ get "/data/:game/:file.json" do |game, file|
data_file = File.expand_path(File.join(settings.data_folder, game, "#{file}.yml"))
halt(404) unless File.exist?(data_file)
json YAML.load_file(data_file)['data'].sample
data = YAML.load_file(data_file)['data']
json Array(data).sample
end