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.
`Listen.to` starts a bunch of background threads that need to perform
some work before they are able to receive events, but it doesn't block
until they are ready, which expose us to a race condition.
With `wait_for_state(:processing_events)` we can ensure that it's ready on
Linux, however on macOS, the Darwin backend has a second background thread
we can't wait on.
As a workaround we wait a bit after the fork to allow that thread to
reach it's listning state.
Given a model with a composite primary key like:
`TravelRoute.primary_key = [:from, :to]`
Calling `TravelRoute.ids` would return an array of identifiers which is
represented by an array of arrays:
```ruby
TravelRoute.all.ids # => [["Ottawa", "New York"], ["London", "Paris"]]
```
Thor, the generator USAGE files and some command USAGE files use
identation to divide the USAGE files into separate sections.
Indentation is also used to describe the options that can be passed
to the commands.
For consistency we should use the same formatting for all commands.
As Thor and most USAGE files already use identation it's a smaller
change to use identation for all commands.
For the examples extra identation is used. This makes them stand out
more allows removing the backticks which make it easier to copy the code
examples.
__Before (example for runner)__
```console
bin/rails runner --help
Commands:
bin/rails runner [<'Some.ruby(code)'> | <filename.rb> | -] # Run Ruby code in the context of your application
bin/rails runner:help [COMMAND] # Describe available commands or one specific command
Options:
-e, [--environment=ENVIRONMENT] # The environment to run `runner` in (e.g. test / development / production).
Examples:
Run `puts Rails.env` after loading the app:
bin/rails runner 'puts Rails.env'
Run the Ruby file located at `path/to/filename.rb` after loading the app:
bin/rails runner path/to/filename.rb
Run the Ruby script read from stdin after loading the app:
bin/rails runner -
You can also use the runner command as a shebang line for your executables:
#!/usr/bin/env /path/to/weblog/bin/rails runner
Product.all.each { |p| p.price *= 2 ; p.save! }
```
__After__
```console
bin/rails runner --help
Usage:
bin/rails runner [<'Some.ruby(code)'> | <filename.rb> | -]
Options:
-e, [--environment=ENVIRONMENT] # The environment to run `runner` in (e.g. test / development / production).
Run Ruby code in the context of your application
Description:
The Rails `runner` allows running Ruby code in the context of your application.
Examples:
Run `puts Rails.env` after loading the app:
bin/rails runner 'puts Rails.env'
Run the Ruby file located at `path/to/filename.rb` after loading the app:
bin/rails runner path/to/filename.rb
Run the Ruby script read from stdin after loading the app:
bin/rails runner -
You can also use the runner command as a shebang line for your executables:
#!/usr/bin/env /path/to/weblog/bin/rails runner
Product.all.each { |p| p.price *= 2 ; p.save! }
```
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.
With the introduction of composite primary keys, a common usecase is querying for records with tuples representing the composite key. This change introduces new syntax to the where clause that allows specifying an array of columns mapped to a list of corresponding tuples. It converts this to an OR-joined list of separate queries, similar to previous implementations that rely on grouping queries.
Given a model with a composite primary key, for example:
`TravelRoute.primary_key = [:from, :to]`
and two objects of the given model, objects `a` and `b`, should be
equal to each other and have the same `hash` value if they have the same
values for the composite primary key, like:
```ruby
a = TravelRoute.new(from: "NYC", to: "LAX")
b = TravelRoute.new(from: "NYC", to: "LAX")
a == b # => true
a.hash == b.hash # => true
```
At the same time, two objects of the given model should not be equal to
each other and should have different `hash` values if they have
different primary key values or no primary key being set, like:
```ruby
a = TravelRoute.new(from: "NYC", to: "LAX")
b = TravelRoute.new(from: "NYC", to: "SFO")
a == b # => false
a.hash == b.hash # => false
TravelRoute.new == TravelRoute.new # => false
TravelRoute.new.hash == TravelRoute.new.hash # => false
```