aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2012-10-10 19:21:11 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2012-10-10 19:21:11 +0200
commitaffd05d28b3fbd0f6cbbf6e6823e352405f4fd34 (patch)
tree7aa8a2cb20a95aabdad56b9d8aa5845a8056a5b8 /activerecord
parent1fc795468525d8622cdca474a54c8310a514aa46 (diff)
parentbadc39fb2fed4d100d2a11fa9a1a2c84c6c33df6 (diff)
downloadrails-affd05d28b3fbd0f6cbbf6e6823e352405f4fd34.tar.gz
rails-affd05d28b3fbd0f6cbbf6e6823e352405f4fd34.tar.bz2
rails-affd05d28b3fbd0f6cbbf6e6823e352405f4fd34.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
-rw-r--r--activerecord/lib/active_record/sanitization.rb17
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb8
3 files changed, 9 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 96270ec0e9..7f39d3083e 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -414,7 +414,7 @@ module ActiveRecord
persisted.map! do |record|
if mem_record = memory.delete(record)
- (record.attribute_names - mem_record.changes.keys).each do |name|
+ ((record.attribute_names & mem_record.attribute_names) - mem_record.changes.keys).each do |name|
mem_record[name] = record[name]
end
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index 42b4cff4b8..f3e47a958e 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -141,23 +141,6 @@ module ActiveRecord
end
end
- def expand_range_bind_variables(bind_vars) #:nodoc:
- expanded = []
-
- bind_vars.each do |var|
- next if var.is_a?(Hash)
-
- if var.is_a?(Range)
- expanded << var.first
- expanded << var.last
- else
- expanded << var
- end
- end
-
- expanded
- end
-
def quote_bound_value(value, c = connection) #:nodoc:
if value.respond_to?(:map) && !value.acts_like?(:string)
if value.respond_to?(:empty?) && value.empty?
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index 86893ec4b3..9b00c21b52 100644
--- a/activerecord/test/cases/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -231,6 +231,14 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
assert_equal "2", categories(:sti_test).authors_with_select.first.post_id.to_s
end
+ def test_create_through_has_many_with_piggyback
+ category = categories(:sti_test)
+ ernie = category.authors_with_select.create(:name => 'Ernie')
+ assert_nothing_raised do
+ assert_equal ernie, category.authors_with_select.detect {|a| a.name == 'Ernie'}
+ end
+ end
+
def test_include_has_many_through
posts = Post.all.merge!(:order => 'posts.id').to_a
posts_with_authors = Post.all.merge!(:includes => :authors, :order => 'posts.id').to_a