diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 2 |
3 files changed, 5 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index f346a19a3a..4ce3b34819 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -478,13 +478,10 @@ module ActiveRecord callback(:before_add, record) yield(record) if block_given? @target ||= [] unless loaded? - index = @target.index(record) - unless @reflection.options[:uniq] && index - if index - @target[index] = record - else + if index = @target.index(record) + @target[index] = record + else @target << record - end end callback(:after_add, record) set_inverse_instance(record, @owner) diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 7517896235..062b010436 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -377,10 +377,6 @@ module ActiveRecord if association.updated? association_id = association.send(reflection.options[:primary_key] || :id) self[reflection.primary_key_name] = association_id - # TODO: Removing this code doesn't seem to matter... - if reflection.options[:polymorphic] - self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s - end end saved if autosave diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c589b32dd8..5898ec3732 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1255,6 +1255,8 @@ MSG replace_named_bind_variables(statement, values.first) elsif statement.include?('?') replace_bind_variables(statement, values) + elsif statement.blank? + statement else statement % values.collect { |value| connection.quote_string(value.to_s) } end |