aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-05-21 19:20:14 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-05-21 19:20:14 +0000
commitb5a6ba683369c712ae99b6be38e736413e9637e1 (patch)
tree56a832526446022b0a06a0bc9a7073015ef1726e /activerecord/lib
parent66586bc168f358e3385416def6eb30ad1242ffe6 (diff)
downloadrails-b5a6ba683369c712ae99b6be38e736413e9637e1.tar.gz
rails-b5a6ba683369c712ae99b6be38e736413e9637e1.tar.bz2
rails-b5a6ba683369c712ae99b6be38e736413e9637e1.zip
Minor style tweaks
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4355 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb4
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb8
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 9c27411a3e..61ad6ab7b6 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -98,8 +98,8 @@ module ActiveRecord
if loaded? && !@reflection.options[:uniq]
@target.size
elsif !loaded? && !@reflection.options[:uniq] && @target.is_a?(Array)
- unsaved_records = Array(@target.detect { |r| r.new_record? }).size
- unsaved_records + count_records
+ unsaved_records = Array(@target.detect { |r| r.new_record? })
+ unsaved_records.size + count_records
else
count_records
end
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index 6a2089c7b8..660e005348 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -13,12 +13,8 @@ module ActiveRecord
record = @reflection.klass.new(attributes)
set_belongs_to_association_for(record)
- if loaded?
- @target << record
- else
- @target ||= []
- @target << record
- end
+ @target ||= [] unless loaded?
+ @target << record
record
end