爲什麼這是不正確的。它有什麼問題?Ruby Class 500錯誤
#!/usr/bin/ruby
require "mysql"
class Game
attr_accessor :id, :name, :urlName, :description, :hits, :categorys, :width, :height, :nilGame
def load(id)
#Load mysql
begin
# connect to the MySQL server
con = Mysql.new('localhost', 'user', 'pass', 'database')
rescue Mysql::Error => e
puts "mysql error"
ensure
# disconnect from server
con.close if con
end
rs = con.query("select * from games where id='#{id}' limit 1")
rs.each_hash do |row|
if row['id'].nil
@nilGame = true
else
@id = id
@name = row['name']
@urlName = row['urlname']
@description = row['description']
@hits = row['hits']
@categorys = row['categorys']
@width = row['width']
@height = row['height']
end
end
con.close
end
end
500錯誤應始終生成詳細的錯誤日誌條目。 – 2010-10-28 09:52:32
唯一的錯誤是在日誌中不存在500錯誤頁面:/ – Will03uk 2010-10-28 09:55:45