I have a query I am running from the console that is eager loading the
address on the people model:
people = People.find(:all,
:include => [:address],
:limit => 50)
Trying to output that to yaml via:
people.to_yaml
Produces the following exception:
TypeError: wrong argument type nil (expected Data)
from /usr/local/lib/ruby/1.8/yaml.rb:387:in `emit'
from /usr/local/lib/ruby/1.8/yaml.rb:387:in `quick_emit'
from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:107:in `to_yaml'
from (irb):10
I don't see any nil data in the include... thoughts?
I've been trying to find the root of this for a few days now and its
getting a little frustrating. I've tried to re-open the class and do the
following (because I noticed the error doesn't occur when I *clone* the
object and then call to_yaml).
module ActiveRecord
class Base
to_old_yaml = self.instance_method(:to_yaml)
define_method(:to_yaml) do
clone = self.clone
clone.id = self.id
oh_boy = to_old_yaml.bind(clone).call
#debugger#testtest = 'test'
return oh_boy
end