Using variable class names breaks has_many?

Hey All,

Any idea why this would work this this:

class Dog
has_many :fleas
end

dog = Dog.find_first
dog.name => “Buster”
dog.class => Dog
dog.fleas => []

store the class

animal_class = dog.class => Dog

dog = animal_class.find_first
dog.name => “Buster”
dog.class => Dog
dog.fleas => method_missing! # hunh?

but this works again

dog = Dog.find_by_id(dog.id)
dog.fleas => []

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

Thanks!

  • Isaac

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs