Basic plugin question

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

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

Did you restart your server?

–Michael

Michael G. wrote:

Did you restart your server?

–Michael

yes

Well, then, that’s obviously not the problem. :slight_smile:

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’

Michael G. wrote:

Well, then, that’s obviously not the problem. :slight_smile:

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.

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

tzinfo (0.3.5)
Daylight-savings aware timezone library

–Michael

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 :slight_smile: