Forum: Ruby on Rails nil object in create_time_zone_conversion_attribute?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
KenM (Guest)
on 2008-12-19 18:24
(Received via mailing list)
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?
Sadeesh V. (Guest)
on 2008-12-19 21:37
(Received via mailing list)
Paste you full error trace here.

Thanks,
Sadeesh.
KenM (Guest)
on 2008-12-19 22:47
(Received via mailing list)
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

On Dec 19, 12:36 pm, sadeesh kumar viswanathan 
<removed_email_address@domain.invalid>
KenM (Guest)
on 2008-12-19 23:24
(Received via mailing list)
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.....
Jeffrey L. Taylor (Guest)
on 2008-12-20 11:33
(Received via mailing list)
Quoting KenM <removed_email_address@domain.invalid>:
> 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
Jeffrey L. Taylor (Guest)
on 2008-12-20 20:26
(Received via mailing list)
Quoting Jeffrey L. Taylor <removed_email_address@domain.invalid>:
> >
>
> 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
Ryan (Guest)
on 2008-12-22 00:10
(Received via mailing list)
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 :-)

Good luck.
Robert M. (Guest)
on 2009-01-03 05:47
I'm getting the same error and a bit baffled.

For me it's happening when I've cached an array of ActiveRecord objects
with Rails.cache and try to read them back. If I'm dealing with an array
of integers it works fine.

Note that this is only happening on my development machine with whatever
Rails' default caching mechanism is. In production, with Memcached, it's
fine, so I just ended up installing Memcached on my development machine
and it worked fine.
Chris L. (Guest)
on 2009-02-07 21:43
Robert M. wrote:
> I'm getting the same error and a bit baffled.
>
> For me it's happening when I've cached an array of ActiveRecord objects
> with Rails.cache and try to read them back. If I'm dealing with an array
> of integers it works fine.
>
> Note that this is only happening on my development machine with whatever
> Rails' default caching mechanism is. In production, with Memcached, it's
> fine, so I just ended up installing Memcached on my development machine
> and it worked fine.

That was exactly my experience, except that I'm a bit of a n00b with RoR
(though not other development) and figured I must be doing something
wrong. Hours and hours later I finally realized that, no, Rails.cache in
2.2.2 (at least) is failing to either store or retrieve ActiveRecord
objects.

Five minutes after reading this I had memcached installed locally and
all my problems were solved.
Joe E. (Guest)
on 2009-04-01 07:35
Chris Luebcke wrote:
> Robert M. wrote:
>> I'm getting the same error and a bit baffled.
>>
>> For me it's happening when I've cached an array of ActiveRecord objects
>> with Rails.cache and try to read them back. If I'm dealing with an array
>> of integers it works fine.
>>
>> Note that this is only happening on my development machine with whatever
>> Rails' default caching mechanism is. In production, with Memcached, it's
>> fine, so I just ended up installing Memcached on my development machine
>> and it worked fine.
>
> That was exactly my experience, except that I'm a bit of a n00b with RoR
> (though not other development) and figured I must be doing something
> wrong. Hours and hours later I finally realized that, no, Rails.cache in
> 2.2.2 (at least) is failing to either store or retrieve ActiveRecord
> objects.
>
> Five minutes after reading this I had memcached installed locally and
> all my problems were solved.

I had the same problem, and same solution.  But I just recently upgraded
to 2.3.2 and everything seems to work fine.  I suppose whatever it was
got fixed?
Michael M. (Guest)
on 2009-04-28 13:47
Joe Ellis wrote:
> Chris Luebcke wrote:
>> Robert M. wrote:
>>> I'm getting the same error and a bit baffled.
>>>
>>> For me it's happening when I've cached an array of ActiveRecord objects
>>> with Rails.cache and try to read them back. If I'm dealing with an array
>>> of integers it works fine.
>>>
>>> Note that this is only happening on my development machine with whatever
>>> Rails' default caching mechanism is. In production, with Memcached, it's
>>> fine, so I just ended up installing Memcached on my development machine
>>> and it worked fine.
>>
>> That was exactly my experience, except that I'm a bit of a n00b with RoR
>> (though not other development) and figured I must be doing something
>> wrong. Hours and hours later I finally realized that, no, Rails.cache in
>> 2.2.2 (at least) is failing to either store or retrieve ActiveRecord
>> objects.
>>
>> Five minutes after reading this I had memcached installed locally and
>> all my problems were solved.
>
> I had the same problem, and same solution.  But I just recently upgraded
> to 2.3.2 and everything seems to work fine.  I suppose whatever it was
> got fixed?

I just upgraded to 2.3.2 on Windows 7 and am getting the error.  Using
file system gives a different error Unable to create directory, and
memcached won't install.  Not sure what to do.
Evan L. (Guest)
on 2009-07-21 04:06
Michael Madrid wrote:
> I just upgraded to 2.3.2 on Windows 7 and am getting the error.  Using
> file system gives a different error Unable to create directory, and
> memcached won't install.  Not sure what to do.

I've seen this problem in 2.3.2 and now in 2.3.3.  The above mentioned
solution does not resolve this issue for me.
bill walton (Guest)
on 2009-07-21 06:52
(Received via mailing list)
Hi Guys,

On Tue, 2009-07-21 at 02:06 +0200, Evan Light wrote:
> Michael Madrid wrote:
> > I just upgraded to 2.3.2 on Windows 7 and am getting the error.  Using
> > file system gives a different error Unable to create directory, and
> > memcached won't install.  Not sure what to do.
>
> I've seen this problem in 2.3.2 and now in 2.3.3.  The above mentioned
> solution does not resolve this issue for me.

Either of you filed a bug report?  With a sandbox app and tests?

Best regards,
Bill
This topic is locked and can not be replied to.