dry up the hash dup and avoid sending nil values

This commit is contained in:
Aaron Patterson
2010-08-11 14:45:07 -07:00
parent a56ee4c9a2
commit 5352a89d50
2 changed files with 15 additions and 11 deletions

View File

@@ -49,12 +49,16 @@ module ActiveRecord
else
"find"
end
options = @reflection.options.dup
(options.keys - [:select, :include, :readonly]).each do |key|
options.delete key
end
options[:conditions] = conditions
the_target = @reflection.klass.send(find_method,
@owner[@reflection.primary_key_name],
:select => @reflection.options[:select],
:conditions => conditions,
:include => @reflection.options[:include],
:readonly => @reflection.options[:readonly]
options
) if @owner[@reflection.primary_key_name]
set_inverse_instance(the_target, @owner)
the_target

View File

@@ -79,13 +79,13 @@ module ActiveRecord
private
def find_target
the_target = @reflection.klass.find(:first,
:conditions => @finder_sql,
:select => @reflection.options[:select],
:order => @reflection.options[:order],
:include => @reflection.options[:include],
:readonly => @reflection.options[:readonly]
)
options = @reflection.options.dup
(options.keys - [:select, :order, :include, :readonly]).each do |key|
options.delete key
end
options[:conditions] = @finder_sql
the_target = @reflection.klass.find(:first, options)
set_inverse_instance(the_target, @owner)
the_target
end