- 15 8月, 2018 6 次提交
-
-
由 bogdanvlviv 提交于
- Move changelog entry of #33530 up in order to preserve the chronology since we always add new entries on the top of a changelog file. - Clarify the changelog entry - Clarify the docs of remove_foreign_key - Ensure reversible of `remove_foreign_key` with `:primary_key` and `:to_table` options.
-
由 Richard Schneeman 提交于
33515 invert remove foreign key support "to_table"
-
由 Matthew Draper 提交于
Add `Array#extract!`
-
由 bogdanvlviv 提交于
Avoid allocating the second array by using `Array#reject!` instead of `Enumerable#partition` in `Array#extract!`. There are benchmarks in order to ensure that the changes speed up the method: ``` begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end class Array def extract_v1!(&block) unless block_given? to_enum(:extract!) { size } else extracted_elements, other_elements = partition(&block) replace(other_elements) extracted_elements end end def extract_v2! return to_enum(:extract!) { size } unless block_given? extracted_elements = [] reject! do |element| extracted_elements << element if yield(element) end extracted_elements end end gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end arrays_for_partition = Array.new(1000) { (0..10000).to_a } arrays_for_extract_v1 = Array.new(1000) { (0..10000).to_a } arrays_for_extract_v2 = Array.new(1000) { (0..10000).to_a } Benchmark.ips do |x| x.report("Array#partition") do arrays_for_partition.each do |numbers| odd_numbers, numbers = numbers.partition { |number| number.odd? } numbers end end x.report("Array#extract_v1!") do arrays_for_extract_v1.each do |numbers| odd_numbers = numbers.extract_v1! { |number| number.odd? } numbers end end x.report("Array#extract_v2!") do arrays_for_extract_v2.each do |numbers| odd_numbers = numbers.extract_v2! { |number| number.odd? } numbers end end x.compare! end ``` The result of the benchmarks: ``` ruby -v ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] ``` ``` Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using benchmark-ips 2.7.2 Using bundler 1.16.1 Warming up -------------------------------------- Array#partition 1.000 i/100ms Array#extract_v1! 1.000 i/100ms Array#extract_v2! 1.000 i/100ms Calculating ------------------------------------- Array#partition 1.390 (± 0.0%) i/s - 7.000 in 5.044843s Array#extract_v1! 2.781 (± 0.0%) i/s - 14.000 in 5.050589s Array#extract_v2! 3.151 (± 0.0%) i/s - 16.000 in 5.080608s Comparison: Array#extract_v2!: 3.2 i/s Array#extract_v1!: 2.8 i/s - 1.13x slower Array#partition: 1.4 i/s - 2.27x slower ``` Avoid `unless`/`else` in favour of an early return. The double-negative of that `else` can be confusing, even though the code layout is nearly the same. Also using of early return would improve `git diff` if we needed to change this method.
-
由 bogdanvlviv 提交于
-
由 bogdanvlviv 提交于
The method removes and returns the elements for which the block returns a true value. If no block is given, an Enumerator is returned instead. ``` numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9] numbers # => [0, 2, 4, 6, 8] ```
-
- 14 8月, 2018 2 次提交
-
-
由 Rich 提交于
remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
-
由 Yuji Yaginuma 提交于
Fix header setting doc in testing guide [ci skip]
-
- 13 8月, 2018 8 次提交
-
-
由 Darren 提交于
-
由 Guillermo Iguaran 提交于
Update coffeelint to 2.1.0
-
由 Prem Sichanugrist 提交于
There was a warning when running `npm install` in Action View: coffee-script@1.11.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) We are not requiring `coffee-script` explicitly, but `coffeelint` does. The latest version, 2.1.0, already fix the dependency package name, so we should upgrade to it to suppress the warning.
-
由 George Claghorn 提交于
Update "Active Record Migrations" guide [ci skip]
-
由 bogdanvlviv 提交于
- Name rails app' files relatively to its root - `structure.sql` => `db/structure.sql` - `schema.rb` => `db/schema.rb` - Clarify rails commands - `db:migrate` => `rails db:migrate` - `db:migrate:status` => `rails db:migrate:status` - Add `/` to the end of `db/migrate` in order to express that it is directory and to keep consistency with `db/migrate/` above. Follow up #33474
-
由 bogdanvlviv 提交于
Context https://github.com/rails/rails/pull/33563#discussion_r208891486. Follow up #33563
-
由 Kasper Timm Hansen 提交于
Add Purpose Metadata to Cookies
-
由 Assain 提交于
Purpose metadata prevents cookie values from being copy-pasted and ensures that the cookie is used only for its originally intended purpose. The Purpose and Expiry metadata are embedded inside signed/encrypted cookies and will not be readable on previous versions of Rails. We can switch off purpose and expiry metadata embedded in signed and encrypted cookies using config.action_dispatch.use_cookies_with_metadata = false if you want your cookies to be readable on older versions of Rails.
-
- 12 8月, 2018 9 次提交
-
-
由 Eileen M. Uchitelle 提交于
Add changelog entry for #31503 [ci skip]
-
由 bogdanvlviv 提交于
Related to #31503
-
由 Richard Schneeman 提交于
Document best practices with old migrations
-
由 Richard Schneeman 提交于
ActiveRecord Guide - sqlite3 foreign keys note
-
由 Kasper Timm Hansen 提交于
`bundle binstubs bundler` should be executed after `bundle install`
-
由 Kasper Timm Hansen 提交于
Use strings instead of symbols on calls to decorate_matching_attribute_types
-
由 Kasper Timm Hansen 提交于
Fix test failure
-
由 bogdanvlviv 提交于
``` ... (snip) ............F Failure: JsonSerializationTest#test_as_json_should_return_a_hash_if_include_root_ in_json_is_true [/home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:145]: Expected: 2006-08-01 00:00:00 UTC Actual: "2006-08-01T00:00:00.000Z" rails test home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:136 (snip) ... ``` Related to #31503
-
由 George Claghorn 提交于
Make active job name prefix static since Rails.env will always be the same
-
- 11 8月, 2018 10 次提交
-
-
由 bogdanvlviv 提交于
Fixes: `bundle binstubs bundler` doesn't generate `bin/bundle` for newly generated Rails app. ``` ... (snip) run bundle binstubs bundler The git source https://github.com/rails/web-console.git is not yet checked out. Please run `bundle install` before trying to start your application run bundle install Fetching https://github.com/rails/web-console.git (snip) ... ``` Related to #33202
-
由 Vinicius Stock 提交于
-
由 Eileen M. Uchitelle 提交于
Fix AM::Serializers::JSON#as_json method for timestamps
-
由 Eileen M. Uchitelle 提交于
Bundler binstubs
-
由 Eileen M. Uchitelle 提交于
Merge pull request #33553 from bogdanvlviv/ensure-load_schema-does_not-output-in-parallel-tests-execution Ensure that running tests in parallel doesn't display schema load output
-
由 George Claghorn 提交于
-
由 George Claghorn 提交于
Closes #33292. [Andrei Makarov & George Claghorn]
-
由 Dillon Welch 提交于
The first thing this method does is run on the argument. This change passes in a string so we don't allocate a bunch of unnecessary extra strings by calling to_s on a symbol over and over.
-
由 Richard Schneeman 提交于
fixes #27157 CSRF protection documentation
-
由 George Claghorn 提交于
-
- 10 8月, 2018 5 次提交
-
-
由 George Claghorn 提交于
perform_or_enqueue instead of enqueue_or_perform
-
由 George Claghorn 提交于
-
由 Robin Dupret 提交于
-
由 Robin Dupret 提交于
The development dependencies installation guides have the installation instructions for FreeBSD in other sections so let's be consistent regarding the dependencies for Active Storage setup. Also fix a few typos.
-
由 Ryuta Kamizono 提交于
Avoid i18n 1.1.0 for now
-