Skip to content
This repository
  • 2 commits
  • 18 files changed
  • 3 comments
  • 1 contributor
2  RAILS_VERSION
... ...
@@ -1 +1 @@
1  
-3.0.0
  1
+3.0.1
4  actionmailer/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * subject is automatically looked up on I18n using mailer_name and action_name as scope as in t(".subject") [JK]
2  actionmailer/lib/action_mailer/version.rb
@@ -2,7 +2,7 @@ module ActionMailer
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
4  actionpack/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * Symbols and strings in routes should yield the same behavior. Note this may break existing apps that were using symbols with the new routes API [José Valim]
2  actionpack/lib/action_pack/version.rb
@@ -2,7 +2,7 @@ module ActionPack
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
4  activemodel/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * Added ActiveModel::MassAssignmentSecurity [Eric Chapweske, Josh Kalderimis]
2  activemodel/lib/active_model/version.rb
@@ -2,7 +2,7 @@ module ActiveModel
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
4  activerecord/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* Introduce a fix for CVE-2010-3993
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * Changed update_attribute to not run callbacks and update the record directly in the database [Neeraj Singh]
17  activerecord/lib/active_record/nested_attributes.rb
@@ -296,9 +296,7 @@ def assign_nested_attributes_for_one_to_one_association(association_name, attrib
296 296
         assign_to_or_mark_for_destruction(record, attributes, options[:allow_destroy])
297 297
 
298 298
       elsif attributes['id']
299  
-        existing_record = self.class.reflect_on_association(association_name).klass.find(attributes['id'])
300  
-        assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy])
301  
-        self.send(association_name.to_s+'=', existing_record)
  299
+        raise_nested_attributes_record_not_found(association_name, attributes['id'])
302 300
 
303 301
       elsif !reject_new_record?(association_name, attributes)
304 302
         method = "build_#{association_name}"
@@ -369,15 +367,12 @@ def assign_nested_attributes_for_collection_association(association_name, attrib
369 367
             association.build(attributes.except(*UNASSIGNABLE_KEYS))
370 368
           end
371 369
 
372  
-        elsif existing_records.count == 0 #Existing record but not yet associated
373  
-          existing_record = self.class.reflect_on_association(association_name).klass.find(attributes['id'])
374  
-          association.send(:add_record_to_target_with_callbacks, existing_record) unless association.loaded?
375  
-          assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy])
376  
-
377 370
         elsif existing_record = existing_records.detect { |record| record.id.to_s == attributes['id'].to_s }
378 371
           association.send(:add_record_to_target_with_callbacks, existing_record) unless association.loaded?
379 372
           assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy])
380 373
 
  374
+        else
  375
+          raise_nested_attributes_record_not_found(association_name, attributes['id'])
381 376
         end
382 377
       end
383 378
     end
@@ -397,7 +392,7 @@ def has_destroy_flag?(hash)
397 392
       ConnectionAdapters::Column.value_to_boolean(hash['_destroy'])
398 393
     end
399 394
 
400  
-    # Determines if a new record should be built by checking for
  395
+    # Determines if a new record should be build by checking for
401 396
     # has_destroy_flag? or if a <tt>:reject_if</tt> proc exists for this
402 397
     # association and evaluates to +true+.
403 398
     def reject_new_record?(association_name, attributes)
@@ -413,5 +408,9 @@ def call_reject_if(association_name, attributes)
413 408
       end
414 409
     end
415 410
 
  411
+    def raise_nested_attributes_record_not_found(association_name, record_id)
  412
+      reflection = self.class.reflect_on_association(association_name)
  413
+      raise RecordNotFound, "Couldn't find #{reflection.klass.name} with ID=#{record_id} for #{self.class.name} with ID=#{id}"
  414
+    end
416 415
   end
417 416
 end
2  activerecord/lib/active_record/version.rb
@@ -2,7 +2,7 @@ module ActiveRecord
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
26  activerecord/test/cases/nested_attributes_test.rb
@@ -178,6 +178,12 @@ def test_should_modify_an_existing_record_if_there_is_a_matching_id
178 178
     assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name
179 179
   end
180 180
 
  181
+  def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record
  182
+    assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find Ship with ID=1234567890 for Pirate with ID=#{@pirate.id}" do
  183
+      @pirate.ship_attributes = { :id => 1234567890 }
  184
+    end
  185
+  end
  186
+
181 187
   def test_should_take_a_hash_with_string_keys_and_update_the_associated_model
182 188
     @pirate.reload.ship_attributes = { 'id' => @ship.id, 'name' => 'Davy Jones Gold Dagger' }
183 189
 
@@ -349,13 +355,10 @@ def test_should_modify_an_existing_record_if_there_is_a_matching_id
349 355
     assert_equal 'Arr', @ship.pirate.catchphrase
350 356
   end
351 357
 
352  
-  def test_should_associate_with_record_if_parent_record_is_not_saved
353  
-    @ship.destroy
354  
-    @pirate = Pirate.create(:catchphrase => 'Arr')
355  
-    @ship = Ship.new(:name => 'Nights Dirty Lightning', :pirate_attributes => { :id => @pirate.id, :catchphrase => @pirate.catchphrase})
356  
-
357  
-    assert_equal @ship.name, 'Nights Dirty Lightning'
358  
-    assert_equal @pirate, @ship.pirate
  358
+  def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record
  359
+    assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find Pirate with ID=1234567890 for Ship with ID=#{@ship.id}" do
  360
+      @ship.pirate_attributes = { :id => 1234567890 }
  361
+    end
359 362
   end
360 363
 
361 364
   def test_should_take_a_hash_with_string_keys_and_update_the_associated_model
@@ -486,11 +489,6 @@ def test_should_take_an_array_and_assign_the_attributes_to_the_associated_models
486 489
     assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.reload.name, @child_2.reload.name]
487 490
   end
488 491
 
489  
-  def test_should_assign_existing_children_if_parent_is_new
490  
-    @pirate = Pirate.new({:catchphrase => "Don' botharr talkin' like one, savvy?"}.merge(@alternate_params))
491  
-    assert_equal ['Grace OMalley', 'Privateers Greed'], [@pirate.send(@association_name)[0].name, @pirate.send(@association_name)[1].name]
492  
-  end
493  
-
494 492
   def test_should_also_work_with_a_HashWithIndifferentAccess
495 493
     @pirate.send(association_setter, HashWithIndifferentAccess.new('foo' => HashWithIndifferentAccess.new(:id => @child_1.id, :name => 'Grace OMalley')))
496 494
     @pirate.save
@@ -554,8 +552,8 @@ def test_should_take_a_hash_with_composite_id_keys_and_assign_the_attributes_to_
554 552
     assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.name, @child_2.name]
555 553
   end
556 554
 
557  
-  def test_should_not_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record
558  
-    assert_nothing_raised ActiveRecord::RecordNotFound do
  555
+  def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_record
  556
+    assert_raise_with_message ActiveRecord::RecordNotFound, "Couldn't find #{@child_1.class.name} with ID=1234567890 for Pirate with ID=#{@pirate.id}" do
559 557
       @pirate.attributes = { association_getter => [{ :id => 1234567890 }] }
560 558
     end
561 559
   end
4  activeresource/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * JSON: set Base.include_root_in_json = true to include a root value in the JSON: {"post": {"title": ...}}. Mirrors the Active Record option.  [Santiago Pastorino]
2  activeresource/lib/active_resource/version.rb
@@ -2,7 +2,7 @@ module ActiveResource
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
4  activesupport/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * Implemented String#strip_heredoc. [fxn]
2  activesupport/lib/active_support/version.rb
@@ -2,7 +2,7 @@ module ActiveSupport
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
4  railties/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+*Rails 3.0.1 (October 15, 2010)*
  2
+
  3
+* No Changes, just a version bump.
  4
+
1 5
 *Rails 3.0.0 (August 29, 2010)*
2 6
 
3 7
 * Application generation: --skip-testunit and --skip-activerecord become --skip-test-unit
2  railties/lib/rails/version.rb
@@ -2,7 +2,7 @@ module Rails
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
  5
+    TINY  = 1
6 6
 
7 7
     STRING = [MAJOR, MINOR, TINY].join('.')
8 8
   end
6  version.rb
@@ -2,9 +2,9 @@ module Rails
2 2
   module VERSION #:nodoc:
3 3
     MAJOR = 3
4 4
     MINOR = 0
5  
-    TINY  = 0
6  
-    BUILD = "rc2"
  5
+    TINY  = 1
  6
+    BUILD = nil
7 7
 
8  
-    STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
  8
+    STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9 9
   end
10 10
 end

Showing you all comments on commits in this comparison.

Ben

API Change in Minor Release? Realy? Crazy?

José Valim
Owner

This is fixing a security vulnerability.

Matthias Bauer

What is the suggested way to assign nested attributes for a new object now?

Something went wrong with that request. Please try again.