I've been testing and can't seem to duplicate the behavior stated in this warning. I've included some tests that pass in a manner contrary to the documented warning, and there is at least one other existing test that shows the same behavior. This warning may have become obsolete as far back as [417] with the added association support for unsaved models.
For example, if I have the following models:
class Owner < ActiveRecord::Base
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :owner
validates_presence_of :owner
end
I get the following:
item = Item.new(:name => 'item1').save
item = Item.new(:name => 'item1', :owner_id => 'invalid_id').save
item = Item.new(:name => 'item1', :owner => Owner.new(:name => 'owner1')).save
item = Item.new(:name => 'item1', :owner_id => valid_owner_id).save
As you see, even when the parent and child models are both new, the save is successful when validation is on the association rather than the foreign key.