diff options
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.rb | 6 |
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)) |