# Tztime (tz\_time\_attributes) problem with callbacks

**URL:** <https://www.ruby-forum.com/t/tztime-tz-time-attributes-problem-with-callbacks/109913>\
**Category:** Rails\
**Created:** [July 20, 2007, 3:46am UTC](https://www.ruby-forum.com/t/tztime-tz-time-attributes-problem-with-callbacks/109913 "2007-07-20T03:46:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevorturk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@trevorturk](https://www.ruby-forum.com/u/trevorturk)\
**Post date:** [July 20, 2007, 3:46am UTC](https://www.ruby-forum.com/t/tztime-tz-time-attributes-problem-with-callbacks/109913/1 "2007-07-20T03:46:45Z")

</div>

I’m having an odd problem with the tztime plugin, where the  
tz\_time\_attributes method seems to have trouble when used within a  
callback.

I’m getting a nil object error:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.utc\_to\_local

vendor/plugins/tztime/lib/tz\_time\_helpers/active\_record\_methods.rb:16:in  
`created_at' app/models/post.rb:27 app/controllers/application.rb:111:in `get\_options’  
app/controllers/application.rb:75:in `set\_timezone’

Here’s the offending code:

[http://eldorado.googlecode.com/svn/trunk/app/models/post.rb](http://eldorado.googlecode.com/svn/trunk/app/models/post.rb)

The second line of the after\_create method seems to be the problem. When  
I remove the tz\_time\_attributes call in the model, the problem goes  
away.

Any ideas on how to work around this issue would be very much  
appreciated.

Thanks!
