mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
dry up the hash dup and avoid sending nil values
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user