aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
diff options
context:
space:
mode:
authorRolf Timmermans <r.timmermans@voormedia.com>2011-03-27 17:18:32 +0200
committerRolf Timmermans <r.timmermans@voormedia.com>2011-03-27 17:18:32 +0200
commit512057d386075f207d8927a5e0ce3943174d5c78 (patch)
treec0b9122469af1e4af74142cc2cad6d560226753c /activerecord/lib/active_record/associations/has_many_through_association.rb
parentd89a7967b5af5c87bbfc268af72287b82541d384 (diff)
parenta9d27c04abf24dc85be061ff9772d71897af02b1 (diff)
downloadrails-512057d386075f207d8927a5e0ce3943174d5c78.tar.gz
rails-512057d386075f207d8927a5e0ce3943174d5c78.tar.bz2
rails-512057d386075f207d8927a5e0ce3943174d5c78.zip
Merge remote-tracking branch 'upstream/master' into desc_tracker
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index acac68fda5..9d2b29685b 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -34,7 +34,9 @@ module ActiveRecord
end
def insert_record(record, validate = true)
+ ensure_not_nested
return if record.new_record? && !record.save(:validate => validate)
+
through_record(record).save!
update_counter(1)
record
@@ -59,6 +61,8 @@ module ActiveRecord
end
def build_record(attributes)
+ ensure_not_nested
+
record = super(attributes)
inverse = source_reflection.inverse_of
@@ -93,6 +97,8 @@ module ActiveRecord
end
def delete_records(records, method)
+ ensure_not_nested
+
through = owner.association(through_reflection.name)
scope = through.scoped.where(construct_join_attributes(*records))