# Basic plugin question

**URL:** <https://www.ruby-forum.com/t/basic-plugin-question/118561>\
**Category:** Rails\
**Created:** [October 28, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561 "2007-10-28T22:29:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 28, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/1 "2007-10-28T22:29:23Z")

</div>

I am working on accommodating time-zones with the following tutorial on  
caboose.se:

[http://blog.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app](http://blog.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app)

It requires installation of tztime and tzinfo\_timezone plugins. I seem  
to have successfully installed these plugins and they appear in my  
vendor/plugins directory. I’ve tried to use this plugin in my  
application the way the tutorial recommends:

class ApplicationController \< ActionController::Base  
around\_filter :set\_timezone  
private

def set\_timezone  
TzTime.zone = current\_user.tz  
yield  
TzTime.reset!  
end

end

But I get the error: “uninitialized constant  
ApplicationController::TzTime” on the “TzTime.zone =” line. Am I  
skipping a step to install the tztime plugin? I don’t have to move  
vendor/plugins/tztime/lib/tz\_time.rb to app/models directory, do I?

Thanks,

Peter

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 28, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/2 "2007-10-28T23:24:03Z")

</div>

Did you restart your server?

–Michael

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 28, 2007, 11:59pm UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/3 "2007-10-28T23:59:02Z")

</div>

Michael G. wrote:

> Did you restart your server?
> 
> –Michael

yes

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 29, 2007, 12:09am UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/4 "2007-10-29T00:09:39Z")

</div>

Well, then, that’s obviously not the problem. 🙂

Run script/console, and try this:

> > TzTime.zone  
> > =\> #\<TzinfoTimezone:0xb9d83e34 @utc\_offset=-21600, @name=“Central Time  
> > (US & Canada)”\>

Do you get that output?

I have this in my config/environment.rb file:

# Use tzinfo library to convert to and from the users timezone

gem ‘tzinfo’  
include TZInfo

TzTime.zone = TimeZone[‘Central Time (US & Canada)’]

# This makes Time.now return time in UTC

ENV[‘TZ’] = ‘UTC’

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 29, 2007, 12:33am UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/5 "2007-10-29T00:33:21Z")

</div>

Michael G. wrote:

> Well, then, that’s obviously not the problem. 🙂
> 
> Run script/console, and try this:
> 
> > > TzTime.zone  
> > > =\> #\<TzinfoTimezone:0xb9d83e34 @utc\_offset=-21600, @name=“Central Time  
> > > (US & Canada)”\>
> 
> Do you get that output?
> 
> I have this in my config/environment.rb file:
> 
> # Use tzinfo library to convert to and from the users timezone
> 
> gem ‘tzinfo’  
> include TZInfo
> 
> TzTime.zone = TimeZone[‘Central Time (US & Canada)’]
> 
> # This makes Time.now return time in UTC
> 
> ENV[‘TZ’] = ‘UTC’

I get “nil” as a response to “TzTime” from console. When I put what you  
have into my own environment.rb file, I get “NameError: uninitialized  
constant TzTime from (irb):1” as a response.

I’m running rails on Locomotive on OSX if that makes any difference.

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 29, 2007, 12:53am UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/6 "2007-10-29T00:53:29Z")

</div>

Here are the gems I have installed that might be related:

tzinfo (0.3.5)  
Daylight-savings aware timezone library

–Michael

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [October 29, 2007, 6:36am UTC](https://www.ruby-forum.com/t/basic-plugin-question/118561/7 "2007-10-29T06:36:29Z")

</div>

Michael G. wrote:

> Here are the gems I have installed that might be related:
> 
> tzinfo (0.3.5)  
> Daylight-savings aware timezone library
> 
> –Michael

Ah, that was it. I even though I was able to install plugins from the  
gem, my app somehow did not have access to the gem. Thanks so much for  
helping me diagnose this issue Michael 🙂
