nil object in create_time_zone_conversion_attribute?

Happily coding away in a Rails 2.2.2 Bort based-app, when I suddenly start getting this error after a few requests:

NoMethodError (You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?):     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:75:in `define_attribute_methods'

This only appears if I authenticate to the application. I can make a couple of requests, then i start getting the above error. While I don't think I've made any changes to cause something like this, when you're so far removed from the low-level bits of the framework, it's hard to tell.

I've searched the net, and while I've found a few hits on this, there are no solutions to be found.

Anyone have any suggestions?

Paste you full error trace here.

Thanks, Sadeesh.

Full trace below...

This issue is not machine specific, as I get the same error on my laptop. Both systems are up to date with respect to gems....

NoMethodError (You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?):     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:75:in `define_attribute_methods'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:71:in `each'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:71:in `define_attribute_methods'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/attribute_methods.rb:242:in `method_missing'     /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/base.rb:2662:in `hash'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:150:in `clear'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:150:in `reload_application'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:178:in `send'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:178:in `evaluate_method'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:166:in `call'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:90:in `run'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:90:in `each'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:90:in `send'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:90:in `run'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/callbacks.rb:277:in `run_callbacks'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:109:in `dispatch_unlocked'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:123:in `dispatch'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:122:in `synchronize'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:122:in `dispatch'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:132:in `dispatch_cgi'     /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:39:in `dispatch'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ rails.rb:76:in `process'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ rails.rb:74:in `synchronize'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/ rails.rb:74:in `process'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 159:in `process_client'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 158:in `each'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 158:in `process_client'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 285:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 285:in `initialize'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 285:in `new'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 285:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 268:in `initialize'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 268:in `new'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb: 268:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/ configurator.rb:282:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/ configurator.rb:281:in `each'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/ configurator.rb:281:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 128:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/ command.rb:212:in `run'     /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails: 281     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:142:in `load_without_new_constant_marking'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:142:in `load'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:521:in `new_constants_in'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:142:in `load'     /opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/ mongrel.rb:64     /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'     /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:153:in `require'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:521:in `new_constants_in'     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:153:in `require'     /opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/ server.rb:49     /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'     /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'     script/server:3

Some further information....

This issue is apparently caused by not passing enough parameters to the route helpers when you have nested resources. For example, I have a gallery, which has a nested image resource. When generating links in the view, I called the helper, but I didn't pass an array with both the gallery and the image, only the image.

The first time presenting the view would work; the second, I would get the stack trace, and from that point on the mongrel instance is hooped, and would not serve any content. It would have to be restarted.

I've fixed the view, and the problem is now resolved.

However, I'm concerned about being able to crash mongrel hard this way.....

Quoting KenM <Andawyr@gmail.com>:

Some further information....

This issue is apparently caused by not passing enough parameters to the route helpers when you have nested resources. For example, I have a gallery, which has a nested image resource. When generating links in the view, I called the helper, but I didn't pass an array with both the gallery and the image, only the image.

The first time presenting the view would work; the second, I would get the stack trace, and from that point on the mongrel instance is hooped, and would not serve any content. It would have to be restarted.

I've fixed the view, and the problem is now resolved.

However, I'm concerned about being able to crash mongrel hard this way.....

I was getting similar errors I started using Rails.cache w/ Rails 2.2.2. I'm using Webrick, not Mongrel. I gave up and went back to using my homegrown caching. With you information about not enough parameters, I may go back and try again.

Jeffrey

Quoting Jeffrey L. Taylor <ror@abluz.dyndns.org>:

Quoting KenM <Andawyr@gmail.com>: > > Some further information.... > > This issue is apparently caused by not passing enough parameters to > the route helpers when you have nested resources. For example, I have > a gallery, which has a nested image resource. When generating links > in the view, I called the helper, but I didn't pass an array with both > the gallery and the image, only the image. > > The first time presenting the view would work; the second, I would get > the stack trace, and from that point on the mongrel instance is > hooped, and would not serve any content. It would have to be > restarted. > > I've fixed the view, and the problem is now resolved. > > However, I'm concerned about being able to crash mongrel hard this > way..... >

I was getting similar errors I started using Rails.cache w/ Rails 2.2.2. I'm using Webrick, not Mongrel. I gave up and went back to using my homegrown caching. With you information about not enough parameters, I may go back and try again.

I went back and looked hard at my code that was crashing. I was missing a parameter to a yield statement. So Rails appears to be brittle around this issue. And maybe Mongrel more brittle than Webrick.

Thanks for the hint. It is always nice to get rid of code that I have to maintain in favor of builtin stuff that someone else maintains.

Jeffrey

I just ran into this problem in an action that had nothing to do with a view (the action was just rendering a status code).

Any chance you are assigning an AR class to a variable, and then calling methods on that variable like so:

saved_class = User # User is AR saved_class.create(whatever)

When I changed that to this:

saved_class = :User Object.const_get(saved_class).create(whatever)

everyone was happy.

I've love to track down why this is happening in my case -- but no time. Plus, that's the way thoughtbot does it in factory_girl, so it's gotta be right :slight_smile:

Good luck.

Hi Guys,