Commit Graph

7709 Commits

Author SHA1 Message Date
Abhay Nikam
1a03cd4913
[ci skip] Documents the --skip-docker rails command line argument (#46823) 2022-12-25 22:04:38 +05:30
Eileen M. Uchitelle
2f0bd27987
Merge pull request #46627 from alison-acuna/46606/docs_serial_tests
Docs: Adds debugger section to contributing guide
2022-12-20 11:41:44 -05:00
Xavier Noria
46f9988c1c
Merge pull request #46769 from corneverbruggen/corneverbruggen-sti-guides-fix 2022-12-20 08:30:39 +01:00
alison-acuna
4af1ffadbe Update guides/source/contributing_to_ruby_on_rails.md
Co-authored-by: Eileen M. Uchitelle <eileencodes@users.noreply.github.com>
2022-12-19 14:17:18 -08:00
Jonathan Hefner
6cacbac68e Fix link to Thor docs [ci-skip] 2022-12-19 15:08:56 -06:00
Max Chernyak
268bf18949
Fix a generators guide link to Thor actions 2022-12-19 15:47:05 -05:00
Corné Verbruggen
bd19260293
Adjust STI preloading docs to run loader collapse also when eager loading
Zeitwerk should still apply collapsing in option #2 of handling STI (Preload a collapsed directory) when eager loading the application, because the collapsing prevents the undesired namespace to be defined. Also when eager loading the application, you don't want that namespace.
2022-12-19 11:38:45 +01:00
Yasuo Honda
d440ba77f8
Merge pull request #46761 from ghiculescu/postgres-config-docs
[docs] Code samples for postgres configs
2022-12-19 11:25:14 +09:00
Alex Ghiculescu
2ba3727d6b [docs] Code samples for postgres configs
The `PostgreSQLAdapter` introduces two configs, `datetime_type` and `create_unlogged_tables`. To configure these you can't just do `config.active_record.whatever` like you can with other configs, it's a bit more involved. So this PR adds some code examples to the [configuration guide](https://edgeguides.rubyonrails.org/configuring.html) to show how to do it.

It was inspired by [this conversation](https://github.com/opf/openproject/pull/11226#discussion_r962624726); the guide should have had the answers!
2022-12-18 12:42:13 -06:00
Jon Dufresne
aa81f67a9e Trim trailing whitespace from *.md files
Fixes the error:

    Run bin/check-changelogs ./rails
    ............F

    Offenses:

    ./rails/railties/CHANGELOG.md:4 Trailing whitespace detected.
2022-12-17 15:27:51 -08:00
Adrianna Chang
0b5a705e1b Hide changes to before_committed! behaviour behind config
As of https://github.com/rails/rails/pull/46525, the behaviour around
before_committed! callbacks has changed: callbacks are run on every
enrolled record in a transaction, even multiple copies of the same record.
This is a significant change that apps should be able to opt into in order
to avoid unexpected issues.
2022-12-15 11:43:51 -05:00
Jonathan Hefner
698f126400
Merge pull request #46732 from skipkayhil/fix-active-record-defaults-order
Fix 7.1 load_defaults ordering [ci skip]
2022-12-14 19:53:23 -06:00
Hartley McGuire
4d677a547d
Fix 7.1 load_defaults ordering
The list should be alphabetical, but belongs_to_required_... is in the
wrong spot
2022-12-14 19:54:23 -05:00
Gert Goet
f5db83f24e
Document new default arguments to Mail's sendmail
Amending 0398459e9a7055e8906a4f649349dd68db14405f
2022-12-14 16:56:50 +01:00
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