diff options
5 files changed, 16 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb index 45b89d2705..ca66d806ef 100644 --- a/activesupport/lib/active_support/core_ext/array/access.rb +++ b/activesupport/lib/active_support/core_ext/array/access.rb @@ -21,7 +21,7 @@ class Array # %w( a b c ).to(-10) # => [] def to(position) if position >= 0 - first position + 1 + take position + 1 else self[0..position] end diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 3d2f50ce49..e10bee5e00 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1549,6 +1549,14 @@ class HashToXmlTest < ActiveSupport::TestCase assert_not_same hash_wia, hash_wia.with_indifferent_access end + + def test_allows_setting_frozen_array_values_with_indifferent_access + value = [1, 2, 3].freeze + hash = HashWithIndifferentAccess.new + hash[:key] = value + assert_equal hash[:key], value + end + def test_should_copy_the_default_value_when_converting_to_hash_with_indifferent_access hash = Hash.new(3) hash_wia = hash.with_indifferent_access diff --git a/activesupport/test/hash_with_indifferent_access_test.rb b/activesupport/test/hash_with_indifferent_access_test.rb index 880457386e..1facd691fa 100644 --- a/activesupport/test/hash_with_indifferent_access_test.rb +++ b/activesupport/test/hash_with_indifferent_access_test.rb @@ -8,10 +8,4 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase assert_equal :old_value, hash[:key] end - def test_frozen_value - value = [1, 2, 3].freeze - hash = {}.with_indifferent_access - hash[:key] = value - assert_equal hash[:key], value - end -end
\ No newline at end of file +end diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 434b308170..373a98bb85 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1134,7 +1134,7 @@ This would generate a query which contains a `LEFT OUTER JOIN` whereas the If there was no `where` condition, this would generate the normal set of two queries. NOTE: Using `where` like this will only work when you pass it a Hash. For -SQL-fragments you need use `references` to force joined tables: +SQL-fragments you need to use `references` to force joined tables: ```ruby Article.includes(:comments).where("comments.visible = true").references(:comments) @@ -1275,7 +1275,7 @@ User.active.where(state: 'finished') # SELECT "users".* FROM "users" WHERE "users"."state" = 'active' AND "users"."state" = 'finished' ``` -If we do want the `last where clause` to win then `Relation#merge` can +If we do want the last `where` clause to win then `Relation#merge` can be used. ```ruby diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE index 23809f897f..e75d5dc4ba 100644 --- a/railties/lib/rails/generators/rails/model/USAGE +++ b/railties/lib/rails/generators/rails/model/USAGE @@ -79,14 +79,14 @@ Available field types: `rails generate model product supplier:references{polymorphic}:index` If you require a `password_digest` string column for use with - has_secure_password, you should specify `password:digest`: + has_secure_password, you can specify `password:digest`: `rails generate model user password:digest` - + If you require a `token` string column for use with - has_secure_token, you should specify `token:token`: + has_secure_token, you can specify `auth_token:token`: - `rails generate model user token:token` + `rails generate model user auth_token:token` Examples: `rails generate model account` @@ -111,4 +111,3 @@ Examples: Test: test/models/admin/account_test.rb Fixtures: test/fixtures/admin/accounts.yml Migration: db/migrate/XXX_create_admin_accounts.rb - |