- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将 Rails 3.2 应用程序升级到 Rails 4.1。每当我尝试启动控制台或服务器时,我都会遇到此错误:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support
/core_ext/time/zones.rb:70:in `rescue in find_zone!': uninitialized constant TZI
nfo::InvalidTimezoneIdentifier (NameError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/a
ctive_support/core_ext/time/zones.rb:55:in `find_zone!'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/a
ctive_support/railtie.rb:20:in `block in <class:Railtie>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
initializable.rb:30:in `instance_exec'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
initializable.rb:30:in `run'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
initializable.rb:55:in `block in run_initializers'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each
_strongly_connected_component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_
component_from'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_c
onnected_component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_
component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
initializable.rb:54:in `run_initializers'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
application.rb:285:in `initialize!'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
railtie.rb:194:in `public_send'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/
railtie.rb:194:in `method_missing'
from C:/sites/RailsApp/config/environment.rb:5:in `<top (required)>'
...
不太确定是什么原因造成的,想知道是否有人有任何建议。我在 irb 中试过这个,没有遇到任何问题(应该会出现错误):
irb(main):001:0> require 'active_support/core_ext/time/zones'
=> true
irb(main):002:0> Time.find_zone!('good')
ArgumentError: Invalid Timezone: f
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/a
ctive_support/core_ext/time/zones.rb:71:in `rescue in find_zone!'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/a
ctive_support/core_ext/time/zones.rb:55:in `find_zone!'
from (irb):3
from C:/Ruby200/bin/irb:12:in `<main>'
Gemfile 包括:
ruby "2.0.0"
gem "rails", "~> 4.1.0.beta1"
gem 'tzinfo-data'
编辑(更多信息):似乎包含 gem 'tzinfo-data' 可能会把事情搞砸?当 gem 位于 gemfile 中时,在 environment.rb 中调用 RailsApp::Application.initialize!
期间似乎从未需要“tzinfo”。然而,当 gem 被移除时,需求正在发生。
最佳答案
在 environment.rb
中初始化应用程序之前需要 tzinfo
gem 为我解决了这个问题。并不能真正解释一切,但似乎可行
# adding this fixes the issue
require 'tzinfo'
# Initialize the rails application
RailsApp::Application.initialize!
编辑:似乎这是 Rails 的问题: https://github.com/rails/rails/issues/13553
关于ruby-on-rails - 未初始化的常量 TZInfo::InvalidTimezoneIdentifier (NameError) - Rails 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20713472/
我正在将 Rails 3.2 应用程序升级到 Rails 4.1。每当我尝试启动控制台或服务器时,我都会遇到此错误: C:/Ruby200/lib/ruby/gems/2.0.0/gems/activ
我正在将 Rails 3.2 应用程序升级到 Rails 4.1。每当我尝试启动控制台或服务器时,我都会遇到此错误: C:/Ruby200/lib/ruby/gems/2.0.0/gems/activ
这是与服务器建立初始 http 连接时日志文件中的错误。奇怪的是,有时服务器可以毫无问题地呈现 http 连接。但更常见的是 TZinfo 错误。 Started GET "/" for 98.206
我是一名优秀的程序员,十分优秀!