# Tzinfo\_timezone plugin - Object::TimeZone not defined

**URL:** <https://www.ruby-forum.com/t/tzinfo-timezone-plugin-object-timezone-not-defined/154905>\
**Category:** Rails\
**Created:** [December 5, 2008, 1:46am UTC](https://www.ruby-forum.com/t/tzinfo-timezone-plugin-object-timezone-not-defined/154905 "2008-12-05T01:46:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shantanu-uab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@shantanu-uab](https://www.ruby-forum.com/u/shantanu-uab)\
**Post date:** [December 5, 2008, 1:46am UTC](https://www.ruby-forum.com/t/tzinfo-timezone-plugin-object-timezone-not-defined/154905/1 "2008-12-05T01:46:15Z")

</div>

I am trying to get my rails project working on a new machine. I am using  
OpenSuse 10.3 and following steps were performed,

1. installed rubygems
2. installed Rails (1.x) using Suse repository - it didn’t have latest  
version.
3. updated gem version and Rails version.
4. installed other gems such rcov
5. installed ‘tzinfo\_timezone’ plugin

Now ‘rake db:create:all’ or ‘script/server’ gives me error as -

```auto

/home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in
`remove_const': constant Object::TimeZone not defined (NameError)
        from
/home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in `send'
        from
/home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in
`evaluate_init_rb'
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:103:in
`evaluate_init_rb'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb:11:in
`silence_warnings'
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:99:in
`evaluate_init_rb'
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:44:in `load'
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin/loader.rb:33:in
`load_plugins'
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin/loader.rb:32:in
`each'
         ... 17 levels...
        from
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
        from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from script/server:3
```

Now, if I comment out the line init.rb:4

```auto
Object.send(:remove_const, :TimeZone)
```

then above rake command and server start runs successfully. What and  
where could be the problem? Where do I define the constant  
Object::TimeZone? Any help for debugging? (The same code runs  
successfully on my old machine.)

Thanks,  
Shantanu.

---

<div class="post-metadata">

**Author:** ![shantanu-uab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@shantanu-uab](https://www.ruby-forum.com/u/shantanu-uab)\
**Post date:** [December 5, 2008, 10:58pm UTC](https://www.ruby-forum.com/t/tzinfo-timezone-plugin-object-timezone-not-defined/154905/2 "2008-12-05T22:58:41Z")

</div>

I don’t know the reason behind this problem. I fixed (bypassed?) it by  
adding if condition in the tzinfo\_timezone plugin’s init.rb file.  
require ‘tzinfo\_timezone’  
New init.rb file:

# remove the existing TimeZone constant

if Object.const\_defined?(:TimeZone)  
Object.send(:remove\_const, :TimeZone)  
end

# Use TzinfoTimezone as the TimeZone class

Object::TimeZone = TzinfoTimezone

Please reply if you know the reason behind this problem.

- 

Shantanu.

Shantanu P. wrote:

> I am trying to get my rails project working on a new machine. I am using  
> OpenSuse 10.3 and following steps were performed,
> 
> 1. installed rubygems
> 2. installed Rails (1.x) using Suse repository - it didn’t have latest  
> version.
> 3. updated gem version and Rails version.
> 4. installed other gems such rcov
> 5. installed ‘tzinfo\_timezone’ plugin
> 
> Now ‘rake db:create:all’ or ‘script/server’ gives me error as -
> 
> ```auto
> 
> > /home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in
> > `remove_const': constant Object::TimeZone not defined (NameError)
> > from
> > /home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in `send'
> > from
> > /home/pavgi/agenda32/vendor/plugins/tzinfo_timezone/init.rb:4:in
> > `evaluate_init_rb'
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:103:in
> > `evaluate_init_rb'
> > from
> > /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb:11:in
> > `silence_warnings'
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:99:in
> > `evaluate_init_rb'
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin.rb:44:in `load'
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin/loader.rb:33:in
> > `load_plugins'
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails/plugin/loader.rb:32:in
> > `each'
> > ... 17 levels...
> > from
> > /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
> > from
> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> > `gem_original_require'
> > from
> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
> > from script/server:3
> ```
> 
> Now, if I comment out the line init.rb:4
> 
> ```auto
> Object.send(:remove_const, :TimeZone)
> ```
> 
> then above rake command and server start runs successfully. What and  
> where could be the problem? Where do I define the constant  
> Object::TimeZone? Any help for debugging? (The same code runs  
> successfully on my old machine.)
> 
> Thanks,  
> Shantanu.

---

<div class="post-metadata">

**Author:** ![shantanu-uab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@shantanu-uab](https://www.ruby-forum.com/u/shantanu-uab)\
**Post date:** [December 5, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/tzinfo-timezone-plugin-object-timezone-not-defined/154905/3 "2008-12-05T23:06:47Z")

</div>

Just checked tzinfo\_timezone plugin mailing list and found the solution:  
Check:  
[http://rubyforge.org/pipermail/tzinfo-users/2008-December/000074.html](http://rubyforge.org/pipermail/tzinfo-users/2008-December/000074.html)

Thanks,  
Shantanu.
