Commit Graph

8626 Commits

Author SHA1 Message Date
Jonathan Hefner 85688a689e Document cache_{inc,dec}rement.active_support events [ci-skip] 2023-05-12 16:14:17 -05:00
Jonathan Hefner 129bdf6ac6 Document cache_delete_matched.active_support event [ci-skip] 2023-05-12 16:14:17 -05:00
Jonathan Hefner 77ed08a91f Clean up Active Support Instrumentation guide [ci-skip]
Some minor rephrasing, punctuation fixes, and helpful linking.
2023-05-12 16:14:17 -05:00
Jonathan Hefner e72eeafa9d Link to API docs [ci-skip] 2023-05-12 16:14:17 -05:00
Jonathan Hefner 22edb9d0c7 Format event names as code [ci-skip] 2023-05-12 16:14:17 -05:00
Eileen M. Uchitelle 437856ba6b
Merge pull request #48175 from eileencodes/fix-type-information-for-mysql
Clean up docs and code using mysql2 when we mean trilogy
2023-05-09 11:18:12 -04:00
Petrik de Heus 161995ba31
Merge pull request #48176 from dzunk/fix_another_ol [ci-skip]
Fix ordered list syntax in development dependencies guide
2023-05-09 17:17:14 +02:00
Matt Duszynski 5756defcda Fix ordered list syntax in development dependencies guide 2023-05-09 10:07:55 -05:00
eileencodes 74898d9b54
Clean up docs and code using mysql2
This PR does the following:

* Adds `trilogy` to lists of adapters where applicable
* Uses `MySQL` instead of adatper names where applicable
* Splits type information into adapters code so that the adapter is set
correctly.
* Fix tests that were using mysql2 when they should be abstract
* Add load hook for trilogy to match mysql2
2023-05-09 10:41:27 -04:00
zzak bb98f9a5ec
Merge pull request #48166 from zzak/ar-associations
Several fixes for AR Associations guide
2023-05-09 18:27:35 +09:00
Matt Duszynski b1820c1ec7 Fix ordered list markdown syntax in multi-DB guide 2023-05-09 01:49:07 -05:00
Jonathan Hefner c924ba0df9 Support :message_pack as cookies serializer
This commit adds support for `:message_pack` and `:message_pack_allow_marshal`
as serializers for `config.action_dispatch.cookies_serializer`, just
like `config.active_support.message_serializer`.

The `:message_pack` serializer can fall back to deserializing with
`AS::JSON`, and the `:message_pack_allow_marshal` serializer can fall
back to deserializing with `AS::JSON` or `Marshal`.  Additionally, the
`:marshal`, `:json`, and `:hybrid` / `:json_allow_marshal` serializers
can now fall back to deserializing with `AS::MessagePack`.  These
behaviors make it easier to migrate between cookies serializers.
2023-05-08 15:00:08 -05:00
Jonathan Hefner af6d83521c Support :message_pack as message serializer
This commit adds support for `:message_pack` as a serializer for
`MessageEncryptor` and `MessageVerifier`, and, consequently, as an
option for `config.active_support.message_serializer`.

The `:message_pack` serializer is implemented via
`ActiveSupport::Messages::SerializerWithFallback` and can fall back to
deserializing with `AS::JSON`.  Additionally, the `:marshal`, `:json`,
and `:json_allow_marshal` serializers can now fall back to deserializing
with `AS::MessagePack`.

This commit also adds support for `:message_pack_allow_marshal` as a
serializer, which can fall back to deserializing with `Marshal` as well
as `AS::JSON`.
2023-05-08 14:39:00 -05:00
Jonathan Hefner 4143c0b3e8 Default message serializer to :json_allow_marshal
Prior to this commit, `config.load_defaults 7.1` would cause old
messages (or messages from older apps) to become unreadable, and
developers were encouraged to manually set
`config.active_support.message_serializer = :json_allow_marshal` in
order to prevent this.

This commit changes the default message serializer set by
`config.load_defaults 7.1` from `:json` to `:json_allow_marshal` so that
upgraded apps can continue to read old messages without additional
configuration.

The intention is to eventually change the default to `:json` (with no
`Marshal` fallback) in Rails 7.2, after some time has passed with apps
generating JSON-serialized messages.

Apps can opt in to JSON-only serialization before Rails 7.2 by manually
setting `config.active_support.message_serializer = :json`.

Fixes #48118.
2023-05-08 12:41:53 -05:00
Jonathan Hefner 9fbfd8100b Unify Message{Encryptor,Verifier} serializer config
In #42843 and #42846, several config settings were added to control the
default serializer for `MessageEncryptor` and `MessageVerifier`, and to
provide a migration path from a default `Marshal` serializer to a
default `JSON` serializer:

* `config.active_support.default_message_encryptor_serializer`
  * Supports `:marshal`, `:hybrid`, or `:json`.
* `config.active_support.default_message_verifier_serializer`
  * Supports `:marshal`, `:hybrid`, or `:json`.
* `config.active_support.fallback_to_marshal_deserialization`
  * Affects `:hybrid` for both `MessageEncryptor` and `MessageVerifier`.
* `config.active_support.use_marshal_serialization`
  * Affects `:hybrid` for both `MessageEncryptor` and `MessageVerifier`.

This commit unifies those config settings into a single setting,
`config.active_support.message_serializer`, which supports `:marshal`,
`:json_allow_marshal`, and `:json` values.  So, for example,

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = true
  config.active_support.use_marshal_serialization = false
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :json_allow_marshal
  ```

and

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = false
  config.active_support.use_marshal_serialization = false
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :json
  ```

This commit also replaces `ActiveSupport::JsonWithMarshalFallback` with
`ActiveSupport::Messages::SerializerWithFallback`, which implements a
generic mechanism for serializer fallback.  The `:marshal` serializer
uses this mechanism too, so

  ```ruby
  config.active_support.default_message_encryptor_serializer = :hybrid
  config.active_support.default_message_verifier_serializer = :hybrid
  config.active_support.fallback_to_marshal_deserialization = false
  config.active_support.use_marshal_serialization = true
  ```

becomes

  ```ruby
  config.active_support.message_serializer = :marshal
  ```

Additionally, the logging behavior of `JsonWithMarshalFallback` has been
replaced with notifications which include the names of the intended and
actual serializers, as well as the serialized and deserialized message
data.  This provides a more targeted means of tracking serializer
fallback events.  It also allows the user to "silence" such events, if
desired, without an additional config setting.

All of these changes make it easier to add migration paths for new
serializers such as `ActiveSupport::MessagePack`.
2023-05-08 12:09:45 -05:00
zzak 156f5081fb
Several fixes for AR Associations guide 2023-05-08 17:57:03 +09:00
Hartley McGuire dcf20cbc56
Use "library.name" format in initializer examples
This updates two instances of custom initializer examples in the docs to
use the standard "library.name" format. Previously, one used just "name"
which can lead to hard to debug "cyclic dependency" errors, and the
other used "name.library" which is not the suggested format.
2023-05-07 18:11:16 -04:00
Jean Boussier 89a5d6ada5 Make Active Record's query cache an LRU
I don't know how prevalent this really is, but I heard several time
about users having memory exhaustion issues caused by the query cache
when dealing with long running jobs.

Overall it seems sensible for this cache not to be entirely unbounded.
2023-05-07 11:16:56 +09:00
Jonathan Hefner d7a562eaa3 Document cache_*_multi events [ci-skip]
This adds documentation for the `cache_read_multi.active_support`,
`cache_write_multi.active_support`, and `cache_delete_multi.active_support`
events to the Instrumentation guide.
2023-05-06 16:14:49 -05:00
Jonathan Hefner daa0cb80db Improve cache performance for bare string values
This commit introduces a performance optimization for cache entries with
bare string values such as view fragments.

A new `7.1` cache format has been added which includes the optimization,
and the `:message_pack` cache format now includes the optimization as
well.  (A new cache format is necessary because, during a rolling
deploy, unupgraded servers must be able to read cache entries from
upgraded servers, which means the optimization cannot be enabled for
existing apps by default.)

New apps will use the `7.1` cache format by default, and existing apps
can enable the format by setting `config.load_defaults 7.1`.  Cache
entries written using the `6.1` or `7.0` cache formats can be read when
using the `7.1` format.

**Benchmark**

  ```ruby
  # frozen_string_literal: true
  require "benchmark/ips"

  serializer_7_0 = ActiveSupport::Cache::SerializerWithFallback[:marshal_7_0]
  serializer_7_1 = ActiveSupport::Cache::SerializerWithFallback[:marshal_7_1]
  entry = ActiveSupport::Cache::Entry.new(Random.bytes(10_000), version: "123")

  Benchmark.ips do |x|
    x.report("dump 7.0") do
      $dumped_7_0 = serializer_7_0.dump(entry)
    end

    x.report("dump 7.1") do
      $dumped_7_1 = serializer_7_1.dump(entry)
    end

    x.compare!
  end

  Benchmark.ips do |x|
    x.report("load 7.0") do
      serializer_7_0.load($dumped_7_0)
    end

    x.report("load 7.1") do
      serializer_7_1.load($dumped_7_1)
    end

    x.compare!
  end
  ```

  ```
  Warming up --------------------------------------
              dump 7.0     5.482k i/100ms
              dump 7.1    10.987k i/100ms
  Calculating -------------------------------------
              dump 7.0     73.966k (± 6.9%) i/s -    367.294k in   5.005176s
              dump 7.1    127.193k (±17.8%) i/s -    615.272k in   5.081387s

  Comparison:
              dump 7.1:   127192.9 i/s
              dump 7.0:    73966.5 i/s - 1.72x  (± 0.00) slower

  Warming up --------------------------------------
              load 7.0     7.425k i/100ms
              load 7.1    26.237k i/100ms
  Calculating -------------------------------------
              load 7.0     85.574k (± 1.7%) i/s -    430.650k in   5.034065s
              load 7.1    264.877k (± 1.6%) i/s -      1.338M in   5.052976s

  Comparison:
              load 7.1:   264876.7 i/s
              load 7.0:    85573.7 i/s - 3.10x  (± 0.00) slower
  ```

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-05-04 16:10:22 -05:00
Jonathan Hefner e2524e574b Support :message_pack as a cache serializer format
This commit adds support for `:message_pack` as an option for
`config.active_support.cache_format_version`.

Cache entries written using the `6.1` or `7.0` formats can be read when
using the `:message_pack` format. Additionally, cache entries written
using the `:message_pack` format can now be read when using the `6.1` or
`7.0` format. These behaviors makes it easy to migrate between formats
without invalidating the entire cache.
2023-05-03 14:22:20 -05:00
Yasuo Honda 2a7cd759be
Merge pull request #48085 from wpank84/patch-1
Update migration examples to showcase database-agnostic raw SQL execution
2023-04-29 07:14:13 +09:00
wpankonien 11efa0445d Update migration example to showcase database-agnostic raw SQL execution 2023-04-28 10:04:13 -05:00
Mike Munroe 67e1e1f901 Clean up bundler install directions 2023-04-27 21:57:00 -04:00
Mike Munroe 77e048577a Link to Action View Form Helpers section in API 2023-04-27 21:37:00 -04:00
Yasuo Honda cc359c077f
Merge pull request #48019 from agrobbin/postgresql-exclusion-constraints-guides
Add a section on exclusion constraints to the AR PostgreSQL guide
2023-04-28 08:48:09 +09:00
Carlos Antonio da Silva f457544f44 Use the skip forgery protection helper in Active Storage guide
The helper method is essentially a wrapper around skipping the callback,
and it simplifies the doc example.

[ci skip]
2023-04-27 13:58:53 -03:00
Alex Robbin 2d8c3495c3
add a section on exclusion constraints to the AR PostgreSQL guide 2023-04-27 08:18:04 -04:00
Petrik de Heus a933125732
Merge pull request #47987 from p8/guides/unlink-asset-pipeline-libs
Unlink headings for alternative libs in assets guide [ci-skip]
2023-04-27 07:23:29 +02:00
alpaca-tc 896d35910a Deprecate `deferrable: true` option of `add_foreign_key`.
`deferrable: true` is deprecated in favor of `deferrable: :immediate`, and
will be removed in Rails 7.2.

Because `deferrable: true` and `deferrable: :deferred` are hard to understand.
Both true and :deferred are truthy values.
This behavior is the same as the deferrable option of the add_unique_key method, added in #46192.

*Hiroyuki Ishii*
2023-04-26 21:48:17 +09:00
Paul McMahon 2918927973
Reword to avoid ambiguity [ci-skip]
As written, it wasn't clear if each migration was run in its own transaction, or all migrations are run in a single transaction.
2023-04-24 11:18:00 +09:00
Petrik de Heus c5a91a3137
Merge pull request #48027 from steve-abrams/sabrams-update-postgres-doc
Add section on INCLUDE option to postgres doc [ci-skip]
2023-04-23 21:45:48 +02:00
Steven Abrams 95f4d75112 Add section on INCLUDE option to postgres doc
- Add a section to the ActiveRecord PostgreSQL doc
  describing use of the INCLUDE index option.
- Related to https://github.com/rails/rails/pull/44803
2023-04-23 13:25:49 -06:00
alpaca-tc 5adc11c45d Add a section on unique constraints to the AR PostgreSQL guide 2023-04-22 23:10:16 +09:00
fatkodima 00b8ce6fe5 Add load hook for `ActiveRecord::ConnectionAdapters::Mysql2Adapter` 2023-04-21 22:00:39 +03:00
Xavier Noria c9780350f2 Modernizes some examples in the autoloading guide
Those examples were obsolete, because nowadays using a reloadable
constant in initializers is not just a bad idea, it is indeed not
possible.

The patch updates the examples accordingly.
2023-04-20 09:57:16 +02:00
Petrik de Heus 835ff1969d
Merge pull request #47998 from p8/guides/index-headings
Fix headings in guides index [ci-skip]
2023-04-20 08:29:48 +02:00
Petrik 4fc9f6214e Fix headings in guides index [ci-skip]
The main heading should be h1 and the next a h2 etc.
2023-04-20 08:14:49 +02:00
Petrik 905ab23705 Use h1 from header for guides title tag [ci-skip]
As the main heading is now a h1, the h1 should be used for the title.
2023-04-20 08:09:41 +02:00
Petrik de Heus 02c1b7ac48
Merge pull request #47977 from p8/guides/headings
Use h1 for guide titles
2023-04-19 23:42:51 +02:00
Petrik 42d20e9174 Unlink headings for alternative libs in assets guide [ci-skip]
By linking to the libraries from the headings the anchor links in the
sidebar link directly to the libraries instead of the library's section.
This behaviour is unexpected.
We can link to the libraries in the section instead.
2023-04-19 13:53:58 +02:00
Petrik e7f91d5d10 Use proper heading for "N + 1 queries" section [ci-skip]
Instead of using a bold pseudo heading, use a real heading.
2023-04-19 12:04:42 +02:00
Petrik 4bd199301e Use h1 for guide titles
Currently the guides use the h1 tag for the guides logo instead of the
guides title. As the guides title is more important in describing the
content of a guide, the title should use the h1 instead.
This also move every other heading to a more important heading (h3 becomes h2, etc.).

This change should improve SEO for the guides.
2023-04-18 22:27:03 +02:00
Chris Hewitt 26b56a72f6
Update upgrading_ruby_on_rails.md 2023-04-17 08:25:40 -04:00
Shozo Hatta 950ffb93d7
Docs: fix misspel on association_basics.md [ci-skip] (#47958)
* Docs: fix misspel on association_basics.md [ci-skip]

* Fix the same misspell on has_one_associations_test.rb
2023-04-17 15:27:23 +09:00
Jonathan Hefner 27d507fa62 Fix marshalling_format_version config name [ci-skip]
Follow-up to #47747.
2023-04-16 18:23:09 -05:00
Xavier Noria bb6eb87be2 User a relative link here 2023-04-15 13:05:26 +02:00
Xavier Noria 6cbd2c97ed Document config.rake_eager_load in the autoloading guide 2023-04-15 13:03:00 +02:00
hachi8833 26f6a1c691 Fix link to configuring.html#config-assets-paths 2023-04-10 20:48:06 +09:00
zzak c34d5508a4
Add link to security guide for CSRF from JS token part 2023-04-10 07:20:40 +09:00
zzak 6492093541
💅 Fix markdownlint errors 2023-04-09 17:33:37 +09:00
Jan Matuszewski e456633ff7
Rewrite Asset Pipeline guide for Rails 7
Add back Sprockets guide(with remarks) to Asset Pipeline guide

Describe Import Maps in asset pipeline guide

Small rewording to first chapters of Asset Pipeline guide

Remove Sass and CoffeScript from Codin Links to Assets section

Remove Preprocessing section from Asset Pipeline guide

Mention dartsass-rails and rewrite beginning Asset Pipeline guide

Add more details on `rails-importmaps` in Asset Pipeline guide

Add alternative libraries section

Align Asset Pipeline guide Sprockets section for Sprockets V4

Improve the introduction to Asset Pipeline guide

Fix formatting in Importmap-rails section of Asset Pipeline guide

Reword, fix typos and add more context to the Asset Pipeline guide

Style, formatting and cleanup changes for asset pipeline guide

Minor style/typo fixes to Asset Pipeline guide

Remove sections dobuled by mistake from asset pipeline guide

Co-authored-by: Alex Ghiculescu <alex@tanda.co>
Co-authored-by: Breno Gazzola <breno.gazzola@gmail.com>
Co-authored-by: Shozo Hatta <hachi8833@gmail.com>
2023-04-09 17:12:13 +09:00
zzak 4e41701b82
Merge pull request #47365 from p8/guides/document-request-js
Document Request.js in the guides [ci-skip]
2023-04-09 16:57:50 +09:00
zzak 450e338628
Merge pull request #47857 from Valerii-Pi/patch-3
Update active_record_validations.md
2023-04-09 16:51:58 +09:00
hachi8833 0de10bd9a3 Fix typo 2023-04-09 15:52:09 +09:00
zzak 24eeed9ef2
Fix WARNING block in security guide 2023-04-09 08:24:33 +09:00
Aaron Patterson a9506eb062
Merge pull request #46992 from ghiculescu/correct-after-commit-order
Run `after_commit` callbacks defined on models in the correct order
2023-04-07 10:12:35 -07:00
Rafael Mendonça França 2f08f9ac2c
Merge pull request #47354 from etiennebarrie/deprecate-ActiveSupport-Deprecation-usage
Deprecate ActiveSupport::Deprecation singleton usage
2023-04-06 10:20:38 -04:00
zzak 4cfaa225bb
Merge pull request #47869 from hachi8833/query_guides_order_desc
Doc: Add `:order` option for find_each docs to Query Guides [ci-skip]
2023-04-06 17:23:16 +09:00
zzak 9f32c51d57
Document verbose logging for Active Job
Follow up to #47839
2023-04-06 08:39:20 +09:00
Alex Ghiculescu 3bcd167c3e Run `after_commit` callbacks defined on models in the correct order 2023-04-05 14:21:33 -06:00
Vipul A M f0148021b7
Merge pull request #47723 from kinduff/patch-1
Add context when changing secret_key_base
2023-04-05 20:30:29 +05:30
Alejandro AR 7a12fa129f Add context when changing secret_key_base
Fixes #47060

Adds additional context of what it will be lost in case the `secret_key_base` changes.
2023-04-05 08:49:01 -06:00
hachi8833 8fb80ac760 Add `:order` option to find_each docs in Query Guides 2023-04-05 17:28:07 +09:00
John Hawthorn 6cd8dddb92
Merge pull request #47630 from bensheldon/action_mailer_around_delivery
Add `*_deliver` callbacks for Action Mailer
2023-04-04 14:58:15 -07:00
Valerii 7ab8ce3342
Update active_record_validations.md 2023-04-04 17:28:57 +03:00
fatkodima f6d56fed27 Add support for logging background job enqueue callers 2023-04-02 03:23:42 +03:00
zzak 0b73361a58
Merge pull request #47825 from toy/patch-1
Update 4_0_release_notes.md
2023-03-31 08:49:39 +09:00
John Hawthorn 1f51d7d441 Revert "Fix guides generator"
This reverts commit 1be5e790eb.
2023-03-30 13:51:28 -07:00
Ivan Kuchin 6e3d143999
Update 4_0_release_notes.md
Use full name ActiveSupport::BufferedLogger in release notes for easier finding
2023-03-30 22:32:37 +02:00
zzak c3db02c201
Prefer bin/rails over rails 2023-03-30 15:16:57 +09:00
zzak f882ff2613
Fix markdown lint re: #47773
* guides/source/active_storage_overview.md:1293: MD031 Fenced code blocks should be surrounded by blank lines
* guides/source/active_storage_overview.md:1301: MD046 Code block style
2023-03-30 10:05:45 +09:00
Ben Sheldon 468d806406 Add `*_deliver` callbacks for Action Mailer 2023-03-29 17:12:19 -07:00
Rafael Mendonça França 4d171a4bde
Merge pull request #47779 from zzak/mdl
Introduce markdownlint for guides
2023-03-29 15:33:41 -04:00
zzak cb6a365a59
Merge pull request #47640 from a5-stable/add-record-not-destroyed
Update documentation about exception handling in destroy callbacks
2023-03-29 09:45:33 +09:00
Petrik de Heus e6884f8b96
Merge pull request #47610 from ghiculescu/less-rake
Mention "rake" less in guides
2023-03-28 18:58:41 +02:00
Jean Boussier dee93277e3 Implement `marshal_dump` and `marshal_load` on ActiveRecord::Base
Fix: https://github.com/rails/rails/issues/47704
Superseed: https://github.com/rails/rails/pull/47722

While the instance variable ordering bug will be fixed in Ruby 3.2.2,
it's not great that we're depending on such brittle implementation detail.

Additionally, Marshalling Active Record instances is currently very inefficient,
the payload include lots of redundant data that shouldn't make it into the cache.

In this new format the serialized payload only contains basic Ruby core or stdlib objects,
reducing the risk of changes in the internal representation of Rails classes.
2023-03-28 16:46:14 +02:00
a5-stable 6e469c1b2b Update documentation for destroy callbacks 2023-03-28 20:03:41 +09:00
Rafael Mendonça França 07048fd994
Copy edit last PR 2023-03-27 20:39:01 +00:00
Rafael Mendonça França 1ed5ef6bb3
Merge pull request #47773 from Roriz/feat/custom-header-direct-upload
Safe for Direct Uploads in js Libraries or Frameworks
2023-03-27 16:37:25 -04:00
Rafael Mendonça França 3b00ec4c30
Merge pull request #47783 from p8/railties/multiline-generator-usage
Output generator usage on two lines
2023-03-27 16:05:33 -04:00
Petrik f7204d8d35 Output generator usage on two lines
All other command usage uses two lines for "Usage: rails command".
This updates the usage of generators to do the same.
It also changes the command to `bin/rails`.
2023-03-27 20:47:04 +02:00
Valerii 910c4bb97a
Update active_record_migrations.md 2023-03-27 18:18:11 +03:00
zzak c3f2b545f8
Introduce markdownlint for guides
This is a follow up to rails#47186, this time for all markdown content.

[markdownlint](https://github.com/markdownlint/markdownlint) is an excellent tool, and I've found it very useful for finding issues in the guides.

Many of the rules are common style issues I'm correcting on PRs, so it will be nice to have that automated.

We should also be able to use the same config with our editors, so that errors show up in real-time 🙏 and will update the contributing docs once this gets merged with how to debug and use mdl appropriately.
2023-03-27 12:14:18 +09:00
zzak 766c26d270
Add a note about installing dev deps on debian linux 2023-03-27 11:17:32 +09:00
zzak 35180ee24a
Update recommended Node.js dev deps guide 2023-03-27 10:33:23 +09:00
Jonathan Hefner 2d43f513af Fix config.after_routes_loaded heading level [ci-skip]
Follow-up to #46539.
2023-03-26 16:44:56 -05:00
Radamés Roriz 1af803b8cd
lint: remove empty space from active_storage docs 2023-03-26 15:58:07 -03:00
Radamés Roriz 896910fb7b
docs: change section to be more details about custom headers 2023-03-26 15:48:30 -03:00
Rafael Mendonça França 6aaa9db647
Merge pull request #46101 from swanson/swanson/missing-attachable-partial
Allow Attachables to override default template when attachment is missing
2023-03-25 12:49:54 -04:00
Rafael Mendonça França 06a8427ec6
Merge pull request #47186 from zzak/rubocop-md
Rubocop markdown snippets
2023-03-25 11:27:47 -04:00
Rafael Mendonça França 166ef00399
Merge pull request #47737 from waymondo/encrypted-rich-text-load-hook
Add `ActiveSupport` load hook for `ActionText::EncryptedRichText`
2023-03-25 11:07:12 -04:00
zzak 0dde0b56e7
Document SQL and IRB comment styles 2023-03-24 17:59:42 +09:00
justin talbott beb43e0182
Add `ActiveSupport` load hook for `ActionText::EncryptedRichText`
Both `ActionText::Record` and `ActionText::RichText` have dedicated `ActiveSupport` load hooks. This adds an
additional hook for `ActionText::EncryptedRichText`, so that external libraries have a similarly simple way
to run code after the subclass is loaded.
2023-03-22 16:00:08 -04:00
Nick Borromeo 6bd100711c Allow SQL Warnings to be ignored using error codes
In https://github.com/rails/rails/pull/46690 the `db_warnings_action` and `db_warnings_ignore` configs where added. The
`db_warnings_ignore` can take a list of warning messages to match against.

At GitHub we have a subscriber that that does something like this but also filters out error codes. There might also be
other applications that filter via error codes and this could be something they can use instead of just the explicit
messages.

This also refactors the adapter tests in order for mysql2 and postgresql adapters to share the same helper when setting
the db_warnings_action and db_warnings_ignore configs
2023-03-20 13:06:22 -07:00
Americo Savinon c0a6963b63 [skip-ci] adding missing config generator line to prevent creating stylesheets inside generators.rb (section: Customizing Your Workflow) 2023-03-20 14:26:28 +01:00
Andrew Novoselac 49283adc16 Run a load hook when TestFixtures is included 2023-03-17 13:36:48 -04:00
Wojciech Wnętrzak e0e7030f99
Add example of simple environment config extending
Follow up to https://github.com/rails/rails/issues/47570

[ci skip]

Update guides/source/configuring.md

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>

Update guides/source/configuring.md

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-03-15 21:23:56 +01:00
zzak dadf46de36
Add rubocop-md for linting guides snippets 2023-03-15 10:48:19 +09:00
Rafael Mendonça França ef4841eac8
Update link to the security announcements list 2023-03-14 17:46:06 +00:00
Étienne Barrié e5af9c298a Deprecate ActiveSupport::Deprecation instance delegation
All methods called on ActiveSupport::Deprecation are delegated to the
singleton instance, but now that each framework has its own Deprecation
instance, it's no longer necessary for internal deprecations.

For external code, instead of using ActiveSupport::Deprecation.warn,
they should create their own instance of the class and call warn on it.
2023-03-14 17:32:52 +01:00
zzak 1b4ea69789
Convert Entryable comment definition to HTML table 2023-03-13 14:33:19 +09:00
Koichi ITO 383981b932 Update GitHub organization of Minitest [ci skip]
https://github.com/seattlerb/minitest is changed to
https://github.com/minitest/minitest.
2023-03-12 03:23:44 +09:00
Xavier Noria 3531ca6853 Iterate instructions for custom namespaces in Rails < 7.1 2023-03-11 06:43:40 +01:00
Alex Ghiculescu 64e60e731a Mention "rake" less in guides
[This blog post](https://dev.to/youngbloodcyb/rake-junior-rails-review-13cc) is about the confusion between `bin/rake` and `bin/rails` commands. The two have mostly [been aliases since Rails 5](3d252a02ae (diff-f5ff9aa07f44111a79d56c09ec37d774b462d97aff68f32490c2e56e74c95783R162)), but this means there's all sorts of advice floating around the internet about which command to use. Is `rake db:migrate` the same as `bin/rails db:migrate`? I know that it is, but I can see why it's confusing for a first timer.

The blog post's suggestion was to have a section in the guides that introduces rake and talks about this distinction. I'm not sure about this. I think if we take up too much space too early in the guide discussing this, it risks confusing people even earlier. But if the advice is hidden away too much, nobody will find it.

Something I think we should do, though, is mention `rake` as little as possible in the guides. Mentions in upgrade guides and release notes are fine, but elsewhere we should avoid using it in places where `bin/rails` does an equivalent job. This PR removes a few `rake` mentions from the guides. Before doing this, I was expecting there to be a lot more, so this PR turned out to be a bit smaller than expected. Still, every little bit helps I think.
2023-03-09 10:14:51 -07:00
Xavier Noria 40f35dda59 Fixes typo 2023-03-06 19:12:02 +01:00
Xavier Noria 930dddb329 Edits to the autoloading guide 2023-03-06 18:59:38 +01:00
Xavier Noria 779c14bf16 Edits in example code and railties CHANGELOG 2023-03-06 13:20:58 +01:00
Xavier Noria 87f3f811a7 Improve support for custom namespaces 2023-03-05 21:35:51 +01:00
Lee Sheppard cc0951dbb8
Update Asset Pipeline Guideline reference to Sass gem (#47491)
* Update Asset Pipeline guide refs to Sass gem

Sassc-rails gem is no longer maintained. Sass is now compiled by Dart. The new dartsass-rails gem wraps the standalone release of the Dart version of Sass.

* Update asset_pipeline.md

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
2023-03-04 17:06:15 +01:00
Rafael Mendonça França 9f60cd8dc7
Merge PR #45463 2023-03-03 22:58:01 +00:00
Rafael Mendonça França 35d574dbfd
Merge pull request #47569 from p8/activemodel/add-model-name-to-missing-attribute-error
Add class name to ActiveModel::MissingAttributeError error message
2023-03-03 17:50:26 -05:00
Rafael Mendonça França fee2bf3f80
Revert "Remove deprecated `children` and `parent_of?` on ActiveSupport::Notifications::Event"
This reverts commit 29679df058.

This method was deprecated in 7.1, so shouldn't be removed until 7.2.
2023-03-03 22:38:21 +00:00
Petrik 661c995f3b Add class name to ActiveModel::MissingAttributeError error message.
When an attribute is missing the current message is unclear about which
class is missing the attribute, especially when there are multiple
classes that could miss the attribute.

By adding the classs name to the error message it is easier to debug:

```ruby
user = User.first
user.pets.select(:id).first.user_id
=> ActiveModel::MissingAttributeError: missing attribute 'user_id' for Pet
```

This also makes the error message more inline with the
UnknownAttributeError message:

```ruby
=> ActiveModel::UnknownAttributeError: unknown attribute 'name' for Person
```

Co-authored-by: Yasuo Honda <yasuo.honda@gmail.com
2023-03-03 14:31:22 +01:00
Shouichi Kamiya f67398fe70 Clarify AS::Representations::RedirectController processes files [skip ci]
Co-authored-by: zzak <zzakscott@gmail.com>
2023-03-03 14:33:32 +09:00
Alex Ghiculescu 0d7a6f50e7 Update Rails welcome image in guides
ref: https://github.com/rails/rails/pull/47550#issuecomment-1452756945
2023-03-02 18:07:45 -07:00
Rafael Mendonça França 18e53fbb2c
Remove deprecated `purge` and `purge_later` methods from the attachments association 2023-03-03 00:38:43 +00:00
Rafael Mendonça França c720b7eba8
Remove deprecated behavior when assigning to a collection of attachments 2023-03-03 00:38:42 +00:00
Rafael Mendonça França 0591de55af
Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods 2023-03-03 00:38:41 +00:00
Rafael Mendonça França 4edaa4120b
Remove deprecated invalid default content types in Active Storage configurations 2023-03-03 00:38:40 +00:00
Rafael Mendonça França 8241178723
Remove deprecated support to instance variables as locals to partials 2023-03-03 00:38:39 +00:00
Rafael Mendonça França 23344d4b8c
Remove deprecated constant `ActionView::Path` 2023-03-03 00:38:37 +00:00
Rafael Mendonça França 7b4affc78b
Remove deprecated support to generate incorrect RFC 4122 UUIDs 2023-03-03 00:38:36 +00:00
Rafael Mendonça França 29679df058
Remove deprecated `children` and `parent_of?` on ActiveSupport::Notifications::Event 2023-03-03 00:38:35 +00:00
Rafael Mendonça França f02998d2b5
Remove implicit conversion of objects into `String` by `ActiveSupport::SafeBuffer` 2023-03-03 00:38:34 +00:00
Rafael Mendonça França f0ddb7709b
Remove deprecated `active_support/core_ext/range/include_time_with_zone` file 2023-03-03 00:38:33 +00:00
Rafael Mendonça França da8e6f6175
Remove deprecated `active_support/core_ext/uri` file 2023-03-03 00:38:32 +00:00
Rafael Mendonça França 34e296d492
Remove deprecated override of `ActiveSupport::TimeWithZone.name` 2023-03-03 00:38:31 +00:00
Rafael Mendonça França e420c3380e
Remove deprecated option to passing a format to `#to_s` 2023-03-03 00:38:30 +00:00
Rafael Mendonça França 4eb6441dd8
Remove deprecated `ActiveSupport::PerThreadRegistry` 2023-03-03 00:38:28 +00:00
Rafael Mendonça França 049dfd4ccf
Remove deprecated `Tasks::DatabaseTasks.schema_file_type` 2023-03-03 00:38:27 +00:00
Rafael Mendonça França 3ec629784c
Remove deprecated override of `Enumerable#sum` 2023-03-03 00:38:26 +00:00
Rafael Mendonça França 96b9fd6f14
Remove deprecated `config.active_record.partial_writes` 2023-03-03 00:38:25 +00:00
Rafael Mendonça França 96c9db1b48
Remove deprecated `ActiveRecord::Base` config accessors 2023-03-03 00:38:24 +00:00
Rafael Mendonça França 696ccbc265
Remove deprecated `poltergeist` and `webkit` (capybara-webkit) driver registration for system testing 2023-03-03 00:38:23 +00:00
Rafael Mendonça França 1e70d0f5d3
Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies` 2023-03-03 00:38:22 +00:00
Rafael Mendonça França 689b277733
Remove deprecated behavior on `Request#content_type` 2023-03-03 00:38:21 +00:00
Carlos Antonio da Silva 7cf65bc335
Merge pull request #47557 from swanson/swanson/remove-macports
Remove references to MacPorts setup
2023-03-02 14:17:31 -03:00
Matt Swanson 6bd9ce40c1 Remove references to macports setup 2023-03-02 10:43:30 -05:00
Lázaro Nixon bde99e52ad
Install dartsass-rails when generating app with sass (#47545) 2023-03-01 06:51:29 +01:00
eileencodes 232aed8504
Allow configs_for to accept a custom hash key
Now that we support a way to register custom configurations we need to
allow applications to find those configurations. This change adds a
`config_key` option to `configs_for` to find db configs where the
configuration_hash contains a particular key.

I have also removed the deprecation for `include_replicas` while I was
in here to make the method signature cleaner. I've updated the upgrade
guide with the removal.
2023-02-28 12:12:08 -05:00
Jeffrey Hardy 4d2eeafa70 Update Action Mailer's deliver_later_queue_name documentation with current defaults
Since Rails 6.1, the default configuration has been to use Active Job's default
queue, achieved by setting the queue name to `nil`.

Refs:
- https://github.com/rails/rails/pull/47408
- https://github.com/rails/rails/pull/47408#discussion_r1118672914
2023-02-27 12:42:14 -05:00
Étienne Barrié 9cfa5e07fd Remove sentence about the namespace of deprecation notification events
All Rails frameworks deprecators have "Rails" as their `gem_name`, and
the `:notify` behavior emits events based on that, so all frameworks
emit their deprecations under the `rails` namespace.

For example: activesupport/lib/active_support/deprecator.rb:5
activesupport/lib/active_support/deprecation.rb:42
activesupport/lib/active_support/deprecation/behaviors.rb:39
2023-02-27 11:24:53 +01:00
Jorge Manrubia 5d7b6d823f
Add option to configure digest algorithm used by Active Record Encryption (#44873)
Before, it was using the configured by Rails. Having a mechanism to configure it
for Active Record encryption makes sense to prevent problems with encrypted content
when the default in Rails changes.

Additionally, there was a bug making AR encryption use the older SHA1 before
`ActiveSupport.hash_digest_class` got initialized to SHA256. This bug was exposed
by https://github.com/rails/rails/pull/44540. We will now set SHA256 as the standard
for 7.1+, and SHA1 for previous versions.
2023-02-27 10:16:41 +01:00
Jon Dufresne da82e587f2 Improve typography of user facing validation messages
With the universal adoption of UTF-8 in browsers, user facing text can
use more optimal Unicode typography. In digital and print design, using
RIGHT SINGLE QUOTATION MARK (U+2019) is normally preferred over
APOSTROPHE (U+0027) in contractions.

For details, see the Unicode Standard Section 6.2:
https://www.unicode.org/versions/Unicode13.0.0/ch06.pdf

> Punctuation Apostrophe. U+2019 right single quotation mark is
> preferred where the character is to represent a punctuation mark, as
> for contractions: “We’ve been here before.” In this latter case,
> U+2019 is also referred to as a punctuation apostrophe.
2023-02-25 08:21:19 -08:00
Jean Boussier cee15555c9 Stop serializing columns as YAML by default
YAML is great for configuration and such, but for serializing arbitrary
data it has many problem, both in term of performance and efficiency
but also in term of security.

As such, we shouldn't let it be the default.

The open question is wether we should provide another default, or
just let users chose what they want based on their own tradeoffs.

Many people would probably suggest JSON as the new default, unfortunately
I don't think it's a good fit either because the parsers available in
Ruby have some wonky behaviors:

```ruby
>> ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(Object.new))
=> {}
>> JSON.load(JSON.dump(Object.new))
=> "#<Object:0x000000012b61a068>"
```

If we were to select another default, I beleive it would need several
properties:

  - It should only serialized a safe list of primitive types.
  - It should explictly raise if attempting to serialize complex types.
2023-02-24 08:55:04 +01:00
Eugene Kenny 6d2e4de19b Sort the results of Dir.glob [ci skip]
Followup to 40143bf9d0.
2023-02-23 08:25:07 +00:00
Peter Boling 40143bf9d0
Dir.glob result must be sorted
Otherwise it is non-deterministic
2023-02-22 22:01:52 -07:00
Carlos Antonio da Silva c4b050984a Fix a couple typos and revise sentence on new column serializer docs
[ci skip]
2023-02-22 20:05:05 -03:00
Jean Boussier 185f2d718d Allow to define the default column serializer
YAML has quite a bit of footguns, as such it's desirable
to be able to substitute it for something else or even
simply to force users to define a serializer explictly for
every serialized columns.
2023-02-22 19:32:28 +01:00