# Require tzinfo on rails 1.2

**URL:** <https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108>\
**Category:** Rails\
**Created:** [February 28, 2007, 9:19am UTC](https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108 "2007-02-28T09:19:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@robbie](https://www.ruby-forum.com/u/robbie)\
**Post date:** [February 28, 2007, 9:19am UTC](https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108/1 "2007-02-28T09:19:25Z")

</div>

I’ve just upgraded rails to 1.2 and now everything breaks when accessing  
pages that use tzinfo.

I get the following errors:

uninitialized constant FriendController::Timezone  
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active\_support/dependencies.rb:477:in  
`const_missing' #{RAILS_ROOT}/app/controllers/friend_controller.rb:22:in`index’

Can someone please tell me how to “require” tzinfo so it can be used in  
any of my controllers?

---

<div class="post-metadata">

**Author:** ![robbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@robbie](https://www.ruby-forum.com/u/robbie)\
**Post date:** [March 1, 2007, 4:54pm UTC](https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108/2 "2007-03-01T16:54:18Z")

</div>

Could this be something to do with this:

Weâ€™ve fixed a bug that allowed libraries from Rubyâ€™s standard library to  
be auto-loaded on reference. Before, if you merely reference the  
Pathname constant, weâ€™d autoload pathname.rb. No more, youâ€™ll need to  
manually require ‘pathname’ now.

(from  
[http://weblog.rubyonrails.org/2006/11/23/rails-1-2-release-candidate-1](http://weblog.rubyonrails.org/2006/11/23/rails-1-2-release-candidate-1))

If so you’ll have to stick require ‘tzinfo’ at the top of files that use  
it.

Fred

---

<div class="post-metadata">

**Author:** ![robbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@robbie](https://www.ruby-forum.com/u/robbie)\
**Post date:** [March 2, 2007, 8:35am UTC](https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108/3 "2007-03-02T08:35:17Z")

</div>

thanks. to get it working I had to:  
#at the top of config/environment.rb  
require ‘tzinfo’

AND

#at the top of my controller  
include TZInfo

Now if only I can get the search\_generator working now…it simply  
refuses to load the Search module. IF anyones got a solution or willing  
to help I’d be happy to throw a few $$ at them for their time.

---

<div class="post-metadata">

**Author:** ![robbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@robbie](https://www.ruby-forum.com/u/robbie)\
**Post date:** [March 1, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/require-tzinfo-on-rails-1-2/87108/4 "2007-03-01T16:56:52Z")

</div>

> Can someone please tell me how to “require” tzinfo so it can be used in  
> any of my controllers?

require ‘tzinfo’ in your config/environment.rb file.

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
