From 6e9bbe3d0b55e86e0613e99df98c001fdebd37a9 Mon Sep 17 00:00:00 2001 From: Alan Harper Date: Thu, 5 Jan 2012 08:26:34 +1100 Subject: [PATCH 1/8] Update ConfirmationValidator docs, correct when the validator runs --- activemodel/lib/active_model/validations/confirmation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index 6573a7d264..e8526303e2 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -37,7 +37,7 @@ module ActiveModel # attribute. # # NOTE: This check is performed only if +password_confirmation+ is not - # +nil+, and by default only on save. To require confirmation, make sure + # +nil+. To require confirmation, make sure # to add a presence check for the confirmation attribute: # # validates_presence_of :password_confirmation, :if => :password_changed? From 693a68f24b399cd86fa0daf010f408ab5d3b3aaf Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Thu, 5 Jan 2012 23:03:53 +0300 Subject: [PATCH 2/8] remove ruby 1.8 example from Array.wrap documentation --- railties/guides/source/active_support_core_extensions.textile | 3 --- 1 file changed, 3 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 1c82a2941f..126e44caaa 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -2238,9 +2238,6 @@ The last point is particularly worth comparing for some enumerables: Array.wrap(:foo => :bar) # => [{:foo => :bar}] Array(:foo => :bar) # => [[:foo, :bar]] - -Array.wrap("foo\nbar") # => ["foo\nbar"] -Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8 There's also a related idiom that uses the splat operator: From 621eb3b666f2df84b7d40d5074eb033204d38146 Mon Sep 17 00:00:00 2001 From: Joost Baaij Date: Fri, 6 Jan 2012 11:53:01 +0100 Subject: [PATCH 3/8] Expanded rdoc about primary keys being protected from mass assignment. People need to make sure they are generated internally or added to attr_accessible so they can be mass assigned (for instance, from an import job). --- .../lib/active_record/attribute_methods/primary_key.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index a7785f8786..7c59664703 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -44,7 +44,8 @@ module ActiveRecord end # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the - # primary_key_prefix_type setting, though. + # primary_key_prefix_type setting, though. Since primary keys are usually protected from mass assignment, + # remember to let your database generate them or include the key in +attr_accessible+. def primary_key @primary_key = reset_primary_key unless defined? @primary_key @primary_key From 6e4183fabbd08449e3f3a62386367a19b19579eb Mon Sep 17 00:00:00 2001 From: codesnik Date: Sat, 7 Jan 2012 02:57:51 +0400 Subject: [PATCH 4/8] Made an example a little more realistic --- actionpack/lib/action_controller/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 98bfe72fef..b6d441d544 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -121,7 +121,7 @@ module ActionController # # def search # @results = Search.find(params[:query]) - # case @results + # case @results.count # when 0 then render :action => "no_results" # when 1 then render :action => "show" # when 2..10 then render :action => "show_many" From d7aff288b145540bc528b97eb306b42c3a60d31b Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Sun, 8 Jan 2012 20:49:53 +0100 Subject: [PATCH 5/8] Substitute "gem" for "plugin" in contributing guide --- railties/guides/source/contributing_to_ruby_on_rails.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 92cb0774de..4fa7fd40c8 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -380,9 +380,9 @@ Now you need to get other people to look at your patch, just as you've looked at h4. Iterate as Necessary -It’s entirely possible that the feedback you get will suggest changes. Don’t get discouraged: the whole point of contributing to an active open source project is to tap into community knowledge. If people are encouraging you to tweak your code, then it’s worth making the tweaks and resubmitting. If the feedback is that your code doesn’t belong in the core, you might still think about releasing it as a plugin. +It’s entirely possible that the feedback you get will suggest changes. Don’t get discouraged: the whole point of contributing to an active open source project is to tap into community knowledge. If people are encouraging you to tweak your code, then it’s worth making the tweaks and resubmitting. If the feedback is that your code doesn’t belong in the core, you might still think about releasing it as a gem. -And then...think about your next contribution! +And then ... think about your next contribution! h3. Rails Contributors From 23f8c635c0c8c9f6fbe810766104a4fa9f6794d4 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Mon, 9 Jan 2012 11:20:52 -0500 Subject: [PATCH 6/8] add documentation explaining reorder behavior --- .../lib/active_record/relation/query_methods.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index c281bead0d..bfb5c27578 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -93,6 +93,16 @@ module ActiveRecord relation end + # Replaces any existing order defined on the relation with the specified order. + # + # User.order('email DESC').reorder('id ASC') # generated SQL has 'ORDER BY id ASC' + # + # Subsequent calls to order on the same relation will be appended. For example: + # + # User.order('email DESC').reorder('id ASC').order('name ASC') + # + # generates a query with 'ORDER BY id ASC, name ASC'. + # def reorder(*args) return self if args.blank? From 274607708c010a18d1d6a4fe1df1c04c88130158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 Jan 2012 01:45:42 -0200 Subject: [PATCH 7/8] Add missing end --- actionpack/lib/action_controller/test_case.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index ac2e0fcb83..5354099f87 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -257,6 +257,7 @@ module ActionController # def test_create # json = {:book => { :title => "Love Hina" }}.to_json # post :create, json + # end # # == Special instance variables # From ce41a368865c341faa0b98b0851b56ba6be6eafb Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Tue, 10 Jan 2012 16:05:36 -0800 Subject: [PATCH 8/8] Update Active Support Constants guide for 1.9. --- .../active_support_core_extensions.textile | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 126e44caaa..7b3878d222 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -376,7 +376,7 @@ NOTE: Defined in +active_support/core_ext/object/instance_variables.rb+. h5. +instance_values+ The method +instance_values+ returns a hash that maps instance variable names without "@" to their -corresponding values. Keys are strings both in Ruby 1.8 and 1.9: +corresponding values. Keys are strings: class C @@ -704,13 +704,11 @@ module X end end -X.local_constants # => ["X2", "X1", "Y"], assumes Ruby 1.8 -X::Y.local_constants # => ["X1", "Y1"], assumes Ruby 1.8 +X.local_constants # => [:X1, :X2, :Y] +X::Y.local_constants # => [:Y1, :X1] -The names are returned as strings in Ruby 1.8, and as symbols in Ruby 1.9. The method +local_constant_names+ always returns strings. - -WARNING: This method returns precise results in Ruby 1.9. In older versions of Ruby, however, it may miss some constants in case the same constant exists in the receiver module as well as in any of its ancestors and both constants point to the same object (objects are compared using +Object#object_id+). +The names are returned as symbols. The method +local_constant_names+ always returns strings. NOTE: Defined in +active_support/core_ext/module/introspection.rb+. @@ -737,8 +735,8 @@ Math.qualified_const_get("E") # => 2.718281828459045 These methods are analogous to their builtin counterparts. In particular, -+qualified_constant_defined?+ accepts an optional second argument in 1.9 -to be able to say whether you want the predicate to look in the ancestors. ++qualified_constant_defined?+ accepts an optional second argument to be +able to say whether you want the predicate to look in the ancestors. This flag is taken into account for each constant in the expression while walking down the path. @@ -759,12 +757,12 @@ end +qualified_const_defined?+ behaves this way: -N.qualified_const_defined?("C::X", false) # => false (1.9 only) -N.qualified_const_defined?("C::X", true) # => true (1.9 only) -N.qualified_const_defined?("C::X") # => false in 1.8, true in 1.9 +N.qualified_const_defined?("C::X", false) # => false +N.qualified_const_defined?("C::X", true) # => true +N.qualified_const_defined?("C::X") # => true -As the last example implies, in 1.9 the second argument defaults to true, +As the last example implies, the second argument defaults to true, as in +const_defined?+. For coherence with the builtin methods only relative paths are accepted.