Working on upgrading an application from Ruby 1.8.6/Rails 2.3.5 to Ruby 1.8.7/Rails3.0.11.
In application.rb, config statements have been moved (from environment.rb) into the:
module AppName
class Application < Rails::Application
...
end
end
block, including the statement:
config.time_zone = 'Eastern Time (US & Canada)'
In the old environment.rb file, there was also some code for initialization of some constants, which i’ve moved into application.rb. I’ve tried it after the module/class block (as it was before) and within it, but the following statement:
Time.zone.parse(external_config_date)
is producing this error:
config/application.rb:49: undefined method `parse’ for nil:NilClass (NoMethodError)
I’m a little baffled by this (as often happens with Rails date/times :-/); mostly it looks like Time.zone is an acceptable way to access the default time zone, but i’ve also seen it said that ‘zone’ is an instance method of Time instead of a class method.
Any insight on this (or thoughts on how to troubleshoot further) much appreciated!
It looks like moving the extra config code from environment.rb into application.rb was my mistake here. ‘Time.zone.parse’ appears to be a Rails add-on, and it hadn’t been enabled in application.rb yet. Moving the config code back to the bottom of environment.rb, after the line
got it working.