0
我在heroku上部署了一個小型sinatra應用程序。當我嘗試訪問該頁面時,出現內部服務器錯誤消息。以下是我從heroku logs
Sinatra應用程序在heroku上拋出內部服務器錯誤
2012-09-29T17:24:18+00:00 app[web.1]: TypeError - can't convert nil into an exact number:
2012-09-29T17:24:18+00:00 app[web.1]: /app/birthday_countdown.rb:9:in `+'
2012-09-29T17:24:18+00:00 app[web.1]: web.rb:5:in `block in <main>'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block in compile!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 levels) in route!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `process_route'
2012-09-29T17:24:18+00:00 app[web.1]: /app/birthday_countdown.rb:9:in `initialize'
2012-09-29T17:24:18+00:00 app[web.1]: web.rb:5:in `new'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in call!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in process_route'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 levels) in route!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in invoke'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/rub
y/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in route!'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/logger.rb:15:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:129:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/head.rb:9:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `block in call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1471:in `synchronize'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:1060:in `block in spawn_threadpool'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:1060:in `call'
2012-09-29T17:24:18+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `catch'
2012-09-29T17:24:18+00:00 app[web.1]: 180.215.44.250 - - [29/Sep/2012 17:24:18] "GET/HTTP/1.1" 500 30 0.0012
2012-09-29T17:24:18+00:00 heroku[router]: GET debo-ka-birthday.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=8ms status=500 bytes=30
我已經在我的應用程序下面的變化得到的,
@month = Time.at(Time.now.utc + Time.zone_offset('IST')).month
@day = Time.at(Time.now.utc + Time.zone_offset('IST')).day
@year = Time.at(Time.now.utc + Time.zone_offset('IST')).year
從
@month = Time.now.month
@day = Time.now.day
@year = Time.now.year
我這樣做是因爲我想根據是時間到印度標準時間,而不是在Heroku服務器上的時間。然而,這已經打破了應用程序,有人可以告訴我如何解決它?
感謝您的回答,我想知道爲什麼在我的機器上運行而不會出現錯誤? – nikhil
Ruby還會識別您的本地時區,因此如果您的機器設置爲IST'zone_offset',則會識別它。 – matt