Sunday, February 6, 2011

[Rails] Re: when is_a? fails and a Foo isn't a Foo

On Feb 6, 9:48 pm, Ryan Mohr <li...@ruby-forum.com> wrote:
> That was my first thought but it doesn't appear to be the case.  If it
> were the class of the returned object should be ActiveRecord::Relation
> instead of Node.
>
It's worth noting that class is a method like any other in ruby and
can easily be overwritten. I don't think this is what is happening
here.
To me, this smells like a code reloading issue. If most of your code
is getting reloading, but Account isn't (eg because it's in a plugin
or something like that), then you can have multiple versions of the
same class in memory. Node refers to the most current one, but the
Account class may be holding onto a previous version, in which case
user.nodes will use that version.
If changing the cache_classes setting (and restarting the app) makes a
difference then your problem is probably a code reloading thing. The
only unusual thing is that with code reloading things, normally it's
the first request that works and subsequent ones that are weird, not
the other way around.

Fred

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate