Forum: Ruby on Rails Using variable class names breaks has_many?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Isaac R. (Guest)
on 2006-04-18 03:23
(Received via mailing list)
Hey All,

Any idea why this would work this this:

class Dog
  has_many :fleas

dog = Dog.find_first   =>  "Buster"
dog.class   =>  Dog
dog.fleas    =>  []

# store the class
animal_class = dog.class   =>  Dog

dog = animal_class.find_first   =>  "Buster"
dog.class   =>  Dog
dog.fleas    =>  method_missing!     # hunh?

# but this works again
dog = Dog.find_by_id(
dog.fleas   =>  []

Is there some AR magic that gets broken by using a variable class name?


- Isaac
This topic is locked and can not be replied to.