From bce0e1493024ccfe78efc93da14740a8d503cb7c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 18 Jan 2005 11:07:03 +0000 Subject: Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@456 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations/has_one_association.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/has_one_association.rb') diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index 74e82f146a..30704b6f7e 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -25,9 +25,9 @@ module ActiveRecord @loaded = true unless @owner.new_record? or obj.nil? or dont_save - return (obj.save ? obj : false) + return (obj.save ? self : false) else - return obj + return (obj.nil? ? nil : self) end end -- cgit v1.2.3