TypeError: $_ value need to be String (nil given)

Hello all,

I am trying to run a unit test in a Rails project of mine (Rails
1.2.2, Ruby 1.8.4 (2005-12-24) [i486-linux]), and am running into the
following error:

  1) Error:
test_pattern_splits(PatternSplitTest):
TypeError: $_ value need to be String (nil given)
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:74:in `split'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:74:in `add_on_blank'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:73:in `add_on_blank'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:409:in `validates_presence_of'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:822:in `run_validations'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:816:in `run_validations'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:780:in `valid_without_callbacks?'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
callbacks.rb:299:in `valid?'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:751:in `save_without_transactions'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
transactions.rb:129:in `save'
<snip>

The model is PatternSplit and the attribute is:
t.column :split, :smallint, :null => false

I assumed this was just a result of a simple bug in my code somewhere,
but I wasn't able to find anything obviously wrong. I decided to break
at
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:74
and debug further, and I came across a very strange condition.

The line causing the problem is:
value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) :
@base[attr.to_s]

Debugging session:
irb(#<ActiveRecord::Errors:0xb77739ac>):001:0> @base.respond_to?
(attr.to_s)
=> true
irb(#<ActiveRecord::Errors:0xb77739ac>):002:0> @base.send(attr.to_s)
TypeError: $_ value need to be String (nil given)
        from (irb):2:in `split'
        from (irb):2:in `each'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/
active_record/validations.rb:75:in `each'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/
active_record/validations.rb:73:in `add_on_blank'
<snip>
irb(#<ActiveRecord::Errors:0xb77739ac>):003:0> attr.to_s
=> "split"
irb(#<ActiveRecord::Errors:0xb77739ac>):004:0> @base.send "split"
TypeError: $_ value need to be String (nil given)
        from (irb):4:in `split'
        from (irb):4:in `each'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/
active_record/validations.rb:75:in `each'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/
active_record/validations.rb:73:in `add_on_blank'
<snip>
irb(#<ActiveRecord::Errors:0xb77739ac>):005:0> @base.split
=> 7
irb(#<ActiveRecord::Errors:0xb77739ac>):006:0> @base.send "split"
=> 7

What is going on here?

Thanks in advance,
jlrc