Commit Graph

8166 Commits

Author SHA1 Message Date
Jonathan Hefner
caaac482d5
Merge pull request #46709 from cjilbert504/belongs-to-association-changed-guide-update
update return values to reflect the proper object class [ci-skip]
2022-12-12 21:49:18 -06:00
Jonathan Hefner
ac3ab2d2ae
Merge pull request #46708 from cjilbert504/errors-where-guides-grammar
fix pluralization and punctuation issues [ci-skip]
2022-12-12 21:45:22 -06:00
Collin Jilbert
696ed4ebdd update return values to reflect the proper object class 2022-12-12 21:11:08 -06:00
Jean Boussier
c5fb44bce4 Fix corrupted guides/source/configuring.md 2022-12-12 11:23:45 +01:00
Jean Boussier
899ed2904e Clarify that config.log_file_size expect a number of bytes 2022-12-12 10:42:36 +01:00
David Heinemeier Hansson
d18fc32999
Use storage/ instead of db/ for sqlite3 db files (#46699)
* Use storage/ instead of db/ for sqlite3 db files

db/ should be for configuration only, not data. This will make it easier to mount a single volume into a container for testing, development, and even sqlite3 in production.
2022-12-12 08:32:12 +01:00
Jonathan Hefner
16eaf44b5a
Merge pull request #46698 from yskkin/remove_columns_doc
documentation for #36589 [ci-skip]
2022-12-11 21:00:51 -06:00
Yoshiyuki Kinjo
8a1c06e9dc [ci skip] documentation for #36589 2022-12-12 08:37:28 +09:00
Xavier Noria
01bc3a4971 Document 4 ways to preload STIs 2022-12-10 21:18:57 +01:00
Petrik de Heus
76ca38e0d1
Merge pull request #46679 from ghiculescu/action-cable-guide [ci-skip]
Clarify how to use a standalone Action Cable server
2022-12-10 12:05:21 +01:00
Alex Ghiculescu
cd04f3bfe4 Clarify how to use a standalone Action Cable server 2022-12-09 12:17:20 -06:00
Jonathan Hefner
a02c23578e
Merge pull request #46662 from adityapandit17/form-helper-guide-fixes
Fixed form helper documentation [ci-skip]
2022-12-08 13:07:20 -06:00
Aditya Pandit
d83f52cede Fixed form helper documentation [ci-skip] 2022-12-08 23:56:06 +05:30
Jean Boussier
2c503ae8b2
Merge pull request #46650 from andynu/mail-2-8-0-sendmail-options
Change sendmail default options to match Mail 2.8.x arguments format.
2022-12-08 11:13:21 +01:00
moenodedev
c45d2f7587
Update the Sentry class name 2022-12-07 13:09:11 -08:00
Andy
0398459e9a Change sendmail default options to match Mail 2.8.x arguments format.
The Mail gem changed format of the delivery method arguments for
sendmail from a string to an array of strings in this commit
7e1196bd29

As the settings are now a sendmail delivery method produces the
following error:
```
.../mail-2.8.0/lib/mail/network/delivery_methods/sendmail.rb:53:in `initialize': :arguments expected to be an Array of individual string args (ArgumentError)
```

This also updates the mail dependency since the new default won't work
with the older versions.
2022-12-06 20:41:09 -05:00
Jonathan Hefner
d79b7d5520
Merge pull request #46623 from cjilbert504/migration-comment-option-grammar
Update text to include comma and add articles before nouns [ci-skip]
2022-12-01 08:51:03 -06:00
Collin Jilbert
37ac589b32 fix pluralization and punctuation issues 2022-12-01 07:44:14 -06:00
Rafael Mendonça França
fa09e3c678
Fix wrong grammar on upgrade guide 2022-11-28 20:03:04 +00:00
Priya Hinduja
58e6e5c898 Fix: Add missing quotes [skip ci] 2022-11-28 10:28:30 +05:30
sampatbadhe
9b5863bd14 Correct closing quotation mark for data-turbo-confirm on button_to example [ci-skip] 2022-11-27 13:26:32 +05:30
Jonathan Hefner
2b2aea4c3a Clarify load_environment_config initializer order [ci-skip]
The description of `load_environment_hook` does mention that
`load_environment_config` runs before it, but that description is at the
distant top of the list.  This commit makes it clear that
`load_environment_config` runs before `load_environment_hook` without
having to read the list from top to bottom.
2022-11-25 15:11:27 -06:00
Collin Jilbert
2e2fed77b6 Update text to include comma and add articles before nouns 2022-11-25 14:54:19 -06:00
cjilbert504
baa9b5f7a0
Update migration generator timestamp behavior
Currently, the documentation says that the generator appends a timestamp to the file name (line: 137), however, the generator prepends the timestamp to the file name as noted on line 111 where it shows `YYYYMMDDHHMMSS_create_products.rb`. This PR updates the guides to more accurately reflect the behavior of where the generator adds the timestamp to the file name.
2022-11-25 11:34:56 -06:00
Jonathan Hefner
e5693c56c6 Add AS::ParameterFilter.precompile_filters
`ActiveSupport::ParameterFilter.precompile_filters` precompiles filters
that otherwise would be passed directly to `ParameterFilter.new`.
Depending on the quantity and types of filters, precompilation can
improve filtering performance, especially in the case where the
`ParameterFilter` instance cannot be retained, such as with per-request
instances in `ActionDispatch::Http::FilterParameters`.

**Benchmark script**

  ```ruby
  # frozen_string_literal: true
  require "benchmark/ips"
  require "benchmark/memory"
  require "active_support"
  require "active_support/parameter_filter"

  ootb = [:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]
  mixed = [:passw, "secret", /token/, :crypt, "salt", /certificate/, "user.otp", /user\.ssn/, proc {}]
  precompiled_ootb = ActiveSupport::ParameterFilter.precompile_filters(ootb)
  precompiled_mixed = ActiveSupport::ParameterFilter.precompile_filters(mixed)

  params = {
    "user" => {
      "name" => :name,
      "email" => :email,
      "password" => :password,
      "ssn" => :ssn,
      "locations" => [
        { "city" => :city, "country" => :country },
        { "city" => :city, "country" => :country },
      ],
    }
  }

  Benchmark.ips do |x|
    x.report("ootb") do
      ActiveSupport::ParameterFilter.new(ootb).filter(params)
    end
    x.report("precompiled ootb") do
      ActiveSupport::ParameterFilter.new(precompiled_ootb).filter(params)
    end
    x.compare!
  end

  Benchmark.ips do |x|
    x.report("mixed") do
      ActiveSupport::ParameterFilter.new(mixed).filter(params)
    end
    x.report("precompiled mixed") do
      ActiveSupport::ParameterFilter.new(precompiled_mixed).filter(params)
    end
    x.compare!
  end

  Benchmark.memory do |x|
    x.report("ootb") do
      ActiveSupport::ParameterFilter.new(ootb).filter(params)
    end
    x.report("precompiled ootb") do
      ActiveSupport::ParameterFilter.new(precompiled_ootb).filter(params)
    end
  end

  Benchmark.memory do |x|
    x.report("mixed") do
      ActiveSupport::ParameterFilter.new(mixed).filter(params)
    end
    x.report("precompiled mixed") do
      ActiveSupport::ParameterFilter.new(precompiled_mixed).filter(params)
    end
  end
  ```

**Results**

  ```
  Warming up --------------------------------------
                  ootb     2.151k i/100ms
      precompiled ootb     4.251k i/100ms
  Calculating -------------------------------------
                  ootb     21.567k (± 1.1%) i/s -    109.701k in   5.086983s
      precompiled ootb     42.840k (± 0.8%) i/s -    216.801k in   5.061022s

  Comparison:
      precompiled ootb:    42840.4 i/s
                  ootb:    21567.5 i/s - 1.99x  (± 0.00) slower
  ```

  ```
  Warming up --------------------------------------
                 mixed     1.622k i/100ms
     precompiled mixed     2.455k i/100ms
  Calculating -------------------------------------
                 mixed     16.085k (± 1.3%) i/s -     81.100k in   5.042764s
     precompiled mixed     24.640k (± 1.0%) i/s -    125.205k in   5.081988s

  Comparison:
     precompiled mixed:    24639.6 i/s
                 mixed:    16085.0 i/s - 1.53x  (± 0.00) slower
  ```

  ```
  Calculating -------------------------------------
                  ootb     2.684k memsize (     0.000  retained)
                          30.000  objects (     0.000  retained)
                          10.000  strings (     0.000  retained)
      precompiled ootb     1.104k memsize (     0.000  retained)
                           9.000  objects (     0.000  retained)
                           1.000  strings (     0.000  retained)
  ```

  ```
  Calculating -------------------------------------
                 mixed     3.541k memsize (     0.000  retained)
                          46.000  objects (     0.000  retained)
                          20.000  strings (     0.000  retained)
     precompiled mixed     1.856k memsize (     0.000  retained)
                          29.000  objects (     0.000  retained)
                          13.000  strings (     0.000  retained)
  ```

This commit also adds `config.precompile_filter_parameters`, which
enables precompilation of `config.filter_parameters`.  It defaults to
`true` for `config.load_defaults 7.1` and above.
2022-11-24 10:26:54 -06:00
fatkodima
e5d15140d2 Avoid validating belongs_to association if it has not changed 2022-11-24 13:04:10 +02:00
Rafael Mendonça França
e32e09228a
Merge pull request #46165 from georgeclaghorn/singular-association-reset
Allow resetting singular associations
2022-11-23 15:25:15 -05:00
Rafael Mendonça França
fba4a024ef
Merge pull request #45119 from p8/guides/add-cors-to-security-guide
Add CORS to the security guide [ci-skip]
2022-11-23 14:59:20 -05:00
George Claghorn
725ee79971 Allow resetting singular associations 2022-11-23 14:53:36 -05:00
Rafael Mendonça França
40563a3ab4
Remove blank lines 2022-11-22 23:55:15 +00:00
Rafael Mendonça França
13e0b5801b
Merge pull request #46551 from donapieppo/main
Add example for data-turbo-confirm on button_to in Working with JavaScript Guide
2022-11-22 18:54:44 -05:00
Chris Salzberg
64962266e3
Add after_routes_loaded hook for Engines to trigger code after application routes have been loaded (#46539)
* Add after_routes_loaded hook

This hook can be used to trigger engine behavior that should only happen
after application routes have been loaded (or reloaded).

* Add changelog entry

* Add note about new after_routes_loaded railtie config to guides

[Rafael Mendonça França + Chris Salzberg]
2022-11-22 15:23:00 -05:00
Pietro
fab044f891 Add example for data-turbo-confirm on button_to in Working with JavaScript Guide 2022-11-22 16:07:52 +01:00
Rafael Mendonça França
a8efccc32e
Merge pull request #46531 from p8/guides/fix-capitalization-of-AJAX
Rename AJAX to Ajax for consistency [ci-skip]
2022-11-21 17:24:09 -05:00
rajivraman
63ea21abf9
Update upgrading_ruby_on_rails.md
Added note that without a cookie rotator, user sessions could be invalidated during the upgrade. This recently happened to us.
2022-11-21 12:05:47 -05:00
Petrik
93c51f92fd Rename AJAX to Ajax for consistency [ci-skip]
Currently we use both `AJAX` (11 times) and `Ajax` (22 times).
Wikipedia uses `Ajax`: https://en.wikipedia.org/wiki/Ajax_(programming)
Mozilla uses `Ajax`: https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX

As `Ajax` is currently used the most and it's preferred by Wikipedia and
Mozilla, we can change all it's occurences to `Ajax`.
2022-11-20 11:17:44 +01:00
Petrik de Heus
2497eb0d5d
Merge pull request #46516 from risinglf/fix-uuid-on-active-storage-guide
Add notice about primary_key_type in ActiveStorage migration guide [ci-skip]
2022-11-19 21:44:59 +01:00
Eileen M. Uchitelle
85edd855d0
Merge pull request #46505 from ytjmt/fix-testing-guide
Fix URL for TIP about database permission problems in Testing Guides [ci-skip]
2022-11-18 08:51:58 -05:00
Luca Ferrari
2e4dc6a6d7 Add notice about primary_key_type in ActiveStorage migration guide 2022-11-17 14:41:31 +01:00
Petrik
bdcd0d3519 Add CORS to the security guide [ci-skip]
The security doesn't mention CORS, even though `rack-cors` is mentioned
in the Gemfile and a CORS initializer is generated for an API-only app.
2022-11-17 00:34:47 +01:00
Hartley McGuire
7b6720dfc8
Raise on assignment to readonly attributes
Previously, assignment would succeed but silently not write to the
database.

The changes to counter_cache are necessary because incrementing the
counter cache for a column calls []=. I investigated an approach to use
_write_attribute instead, however counter caches are expected to resolve
attribute aliases so write_attribute/[]= seems more correct.

Similarly, []= was replaced with _write_attribute in merge_target_lists
to skip the overriden []= and the primary key check. attribute_names
will already return custom primary keys so the primary_key check in
write_attribute is not needed.

Co-authored-by: Alex Ghiculescu <alex@tanda.co>
2022-11-16 17:14:54 -05:00
Petrik de Heus
59f338baae
Merge pull request #46265 from bdewater/query-logs-docs [ci-skip]
Update Active Record Query Logs docs
2022-11-16 21:36:53 +01:00
ytjmt
5cd84c96aa
Fix URL for TIP about database permission problems 2022-11-16 22:33:36 +09:00
Jonathan Hefner
f6a8cb42d8 Fix Active Record Encryption credentials example [ci-skip]
Active Record Encryption uses the `active_record_encryption` credentials
namespace, rather than `active_record`.`encryption`.
2022-11-15 13:57:15 -06:00
Jonathan Hefner
7bcee19060 Add MDN links for security headers [ci-skip] 2022-11-15 13:57:15 -06:00
Jonathan Hefner
589bc9645c Fix link to "Conditional GET Support" section [ci-skip] 2022-11-15 13:57:15 -06:00
Jonathan Hefner
a4dbfc0089 Use yaml code fence [ci-skip]
This changes a `bash` code fence with `cat` output to a `yaml` code
fence for proper YAML syntax highlighting.  This also fixes a typo in
the YAML content.
2022-11-15 13:57:15 -06:00
Jonathan Hefner
86517b00a7 Add *_check_constraint actions to Migrations guide [ci-skip]
Closes #45356.

Co-authored-by: Nataliya Terskaya <nt@Nataliyas-MacBook-Pro.local>
2022-11-15 13:57:15 -06:00
Rafael Mendonça França
b85296efe6
Merge pull request #45932 from marcoroth/migrate-guides-to-turbo
Migrate Rails Guides from `Turbolinks` to `Turbo`
2022-11-14 18:33:44 -05:00
Bart de Water
7a56b7602c Update Active Record Query Logs docs
Fixes https://github.com/rails/rails/issues/46103 and some things I found along the way.
The major changes:
- Explicitly show how to enable the functionality
- Add missing namespaced_controller default tag
- Remove mention of ActiveSupport::ExecutionContext since that is nodoc'ed internal API since commit 6bad959565900499325d4239266cbb1f1f8e4056, instead show the ActiveSupport::CurrentAttributes example of a current account
- Mention the SQLCommenter format

Also added a section in the 'Debugging Rails Applications' guide for discoverability.
2022-11-14 17:06:15 -05:00