Re: nil object in create_time_zone_conversion_attribute?

Ryan
Sun, 21 Dec 2008 22:09:49 -0000

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.

On Dec 20, 1:26 pm, "Jeffrey L. Taylor"
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>
wrote:
> Quoting Jeffrey L. Taylor
<r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>:
>
>
>
>
>
> > Quoting KenM <Anda...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> > > 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com