Commit Graph

78278 Commits

Author SHA1 Message Date
Rafael Mendonça França 81ee5dcdf4
Merge pull request #39538.
Closes #39538.
2020-11-02 20:42:40 +00:00
Vipul A M fdfac8760f
Although libraries support both formats of sign before and after DIGITS(ex: https://github.com/moment/luxon/pull/683, https://github.com/moment/moment/issues/2408), many do not.
For example PG refers to https://www.ietf.org/rfc/rfc3339.txt when converting(Ref: https://www.postgresql.org/docs/current/datatype-datetime.html)

According to the ref there is no explicit mention of allowing sign before the parts, which reads as below:

 Durations:

    dur-second        = 1*DIGIT "S"
    dur-minute        = 1*DIGIT "M" [dur-second]
    dur-hour          = 1*DIGIT "H" [dur-minute]
    dur-time          = "T" (dur-hour / dur-minute / dur-second)
    dur-day           = 1*DIGIT "D"
    dur-week          = 1*DIGIT "W"
    dur-month         = 1*DIGIT "M" [dur-day]
    dur-year          = 1*DIGIT "Y" [dur-month]
    dur-date          = (dur-day / dur-month / dur-year) [dur-time]

    duration          = "P" (dur-date / dur-time / dur-week)

We should not attempt to move sign forward in this case.
2020-11-02 20:41:48 +00:00
Rafael França 890035fd4a
Merge pull request #40365 from ankurp/fix/standardize-js-package-name
Follow npm/JS standard for package name
2020-11-02 15:29:41 -05:00
Eugene Kenny 67e69e8db4
Merge pull request #38829 from cbisnett/host_authorization_exclude
Add request exclusion to Host Authorization
2020-11-02 20:22:35 +00:00
Rafael França 5f40eca4a5
Merge pull request #39832 from p8/scaffold-generator-inflection-check
Raise if camelcase inflection impossible in generator
2020-11-02 15:18:26 -05:00
Chris Bisnett 1f767407cb Add request exclusion to Host Authorization
In the same way that requests may need to be excluded from forced SSL,
requests may also need to be excluded from the Host Authorization
checks. By providing this additional flexibility more applications
will be able to enable Host Authorization while excluding requests
that may not conform. For example, AWS Classic Load Balancers don't
provide a Host header and cannot be configured to send one. This means
that Host Authorization must be disabled to use the health check
provided by the load balancer. This change will allow an application
to exclude the health check requests from the Host Authorization
requirements.

I've modified the `ActionDispatch::HostAuthorization` middleware to
accept arguments in a similar way to `ActionDispatch::SSL`. The hosts
configuration setting still exists separately as does the
hosts_response_app but I've tried to group the Host Authorization
settings like the ssl_options. It may make sense to deprecate the
global hosts_response_app if it's only used as part of the Host
Authorization failure response. I've also updated the existing tests
as the method signature changed and added new tests to verify the
exclusion functionality.
2020-11-02 20:16:29 +00:00
Eugene Kenny 872e757145
Merge pull request #40421 from ayamomiji/master
Fix rename_index removing old index with symbols
2020-11-02 20:09:34 +00:00
Kasper Timm Hansen 473a6500e7
Merge pull request #40515 from p8/sdoc-2.0.0
Use official sdoc gem instead of fork [skip ci]
2020-11-02 21:04:17 +01:00
Petrik f9ae061bfd Use official sdoc gem instead of fork [skip ci] 2020-11-02 20:58:37 +01:00
Eugene Kenny 56c9be11ad Tidy up comments in environment configuration files [ci skip]
https://guides.rubyonrails.org/api_documentation_guidelines.html#wording
2020-11-02 19:51:58 +00:00
Eugene Kenny b7eaaf73fb Update comment about reloading in development.rb [ci skip]
This comment predates the existence of `reload_classes_only_on_change`.
2020-11-02 19:36:26 +00:00
Eileen M. Uchitelle bd28db1400
Merge pull request #40510 from eileencodes/add-connected_to_many
Add `connected_to_many` API
2020-11-02 14:34:57 -05:00
Nate Berkopec 7547a6b073
Mark Reaper thread as fork-safe w/thread-local variable (#40399)
Re: https://github.com/rails/rails/issues/37066#issuecomment-709403972

Puma (and some other multi-threaded application servers) may check the `Thread` list before and after forking to look for any threads that may have been running during a call to `fork`. Threads running during a `fork` can leave memory and resources open and potentially cause leaks or deadlocks.

However, the Reaper thread in ActiveRecord cannot orphan any resources or memory, and will be cleaned up after forking.

Setting this thread local variable allows Puma and other application servers to ignore this thread for the purpose of displaying warnings to users about threads present and running during `fork`.

Co-authored-by: Eugene Kenny <elkenny@gmail.com>
2020-11-02 18:39:27 +00:00
eileencodes 27d51da866
Add `connected_to_many` API
Now that we have implemented granular connection swapping in #40370
we need a new API that will allow connections to multiple databases. The
reason we need this API is it will prevent deep nesting in cases where
we know that we want 3 of our 5 databases to connect to reading and
leave the rest on writing.

With this API, instead of writing:

```ruby
AnimalsRecord.connected_to(role: :reading) do
  MealsRecord.connected_to(role: :reading) do
    Dog.first # read from animals replica
    Dinner.first # read from meals replica
    Person.first # read from primary writer
  end
end
```

This API would allow you to write:

```ruby
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
  Dog.first # read from animals replica
  Dinner.first # read from meals replica
  Person.first # read from primary writer
end
```

This would come in especially handy for deeper nesting past 2 databases.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-11-02 13:29:48 -05:00
Eileen M. Uchitelle a7f29d357b
Merge pull request #40511 from eileencodes/add-option-for-handling-strict-loading
Allow applications to change the behavior for a strict loading violation
2020-11-02 13:26:36 -05:00
Rafael Mendonça França 7eed607b12
Fix CHANGELOG [ci skip] 2020-11-02 18:16:45 +00:00
Rafael França af91d9a1c5
Merge pull request #40434 from filipe-sabella/pass-in-base-in-validation-messages
Pass in base to Error.human_attribute_names
2020-11-02 13:15:53 -05:00
Rafael Mendonça França f8a1a8acc3
Merge pull request #39953
Closes #39953.
2020-11-02 18:12:11 +00:00
Edouard Chin 868866c1fd
Allow a new `server` Railtie block:
- This is similar to other railties blocks (such as `console`,
  `tasks` ...). The goal of this block is to allow the application
  or a railtie to load code after the server start.

  The use case can be to fire the webpack or react server in
  development or start some job worker like sidekiq or resque.

  Right now, all these tasks needs to be done in a separate
  shell and gem maintainer needs to add documentation on
  how to run their libraries if another program needs to run
  next to the Rails server.

  This feature can be used like this:

  ```ruby
    class SuperRailtie < Rails::Railtie
      server do
        WebpackServer.run
      end
    end
  ```
2020-11-02 18:11:41 +00:00
eileencodes 656c6faf78
Allow applications to change the behavior for a strict loading violation
Originally strict loading violations would always raise an error if
turned on for an association. This change allows for an application to
optionally log instead of raise. The behavior here is similar to how
strong parameters work. By default all environments will raise. An
application may want to use log in production while working on finding
all lazily loaded associations.

Set `config.active_record.action_on_strict_loading_violation` to `:log`
in your application to log instead of raise.
2020-11-02 13:01:50 -05:00
Rafael Mendonça França 4dd61b4318
Prepare the maintenance policy to match the 6.1 release
[ci skip]
2020-11-02 18:00:47 +00:00
Jonathan Hefner 71f743ffdd
Merge pull request #40500 from jonathanhefner/guides-irb-code-fences
Use irb code fences where applicable [ci-skip]
2020-11-02 11:56:34 -06:00
Jonathan Hefner 9f7d2656fa
Merge pull request #40481 from jonathanhefner/guide-getting_started-rework
Rework Getting Started guide [ci-skip]
2020-11-02 11:55:48 -06:00
Rafael França 0300aa802a
Merge pull request #40504 from tbrisker/paramobjects
Reduce object allocations in param wrapping
2020-11-02 12:52:24 -05:00
Rafael França d52ece70f0
Merge pull request #40492 from nateberkopec/puma5
Upgrade Puma to 5.x
2020-11-02 12:48:32 -05:00
Rafael França 7f912ba27e
Merge pull request #40513 from jonathanhefner/tweak-generated-filter_parameters
Tweak generated default filter_parameters
2020-11-02 12:46:52 -05:00
Jonathan Hefner b38c2c1a84 Tweak generated default filter_parameters
Follow-up to #34218.

This removes some filters that could filter innocuous fields such as
`author_name`.  Filtering such fields might be surprising, especially to
people generating their first Rails app.

This commit also changes the `:password` filter to `:passw` so that it
can also filter fields such as `passwd`.
2020-11-02 10:12:32 -06:00
eileencodes 3c99817394
Fix broken sqlite3_mem tests
I put this test in the wrong place and it broke the sqlite3_mem tests.
This test shouldn't run on sqlite3_mem.
2020-11-02 10:44:57 -05:00
eileencodes 9c8a7f4308
Fix `while_preventing_writes` for legacy version
We need to pass the block along to the connection handler's
`while_preventing_writes`.
2020-11-02 09:22:12 -05:00
eileencodes 0919871bda
Add tests for `current_preventing_writes`
Ensure that the new version and legacy versions work as expected.
2020-11-02 09:21:15 -05:00
eileencodes 197b1bbc1a
Reorder code and add docs to `current_*` methods
Reorders the methods since we usually go role, shard, then prevent
writes. I think it makes it easier to read.

Added documention to the methods for `current_shard` and
`current_preventing_writes`. These were originally marked as `nodoc` but
that doesn't make sense, apps may need to call these so we should make
them public.
2020-11-02 09:19:22 -05:00
Eugene Kenny 2dbd2e41f8
Merge pull request #40497 from lowski/patch-1
Guides: update description of `to_prepare` event in the Configuration section
2020-11-02 08:34:45 +00:00
Eugene Kenny 2a8fe4f821 Remove an unused Action View test fixture
The test that used this was deleted in
4642ca9640.
2020-11-01 23:25:29 +00:00
Jonathan Hefner 3c9d7a268f Use irb code fences where applicable [ci-skip]
Using `irb` code fences and the appropriate prompt syntax results in
better syntax highlighting.
2020-11-01 16:29:18 -06:00
Nate Berkopec b8af0fd2d7
Upgrade Puma to 5.x 2020-11-01 14:50:27 -07:00
Jonathan Hefner 3beb8c0fe0 Update GS guide code for Adding a Second Model [ci-skip] 2020-11-01 11:51:50 -06:00
Jonathan Hefner 8fa3b80ba2 Edit GS guide § Deleting an Article [ci-skip]
Fixes #39920.
Resolves #38329.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
Co-Authored-By: Petrik de Heus <petrik@deheus.net>
2020-11-01 11:49:29 -06:00
Jonathan Hefner 0d3f15a022 Add GS guide § Finishing Up (Updating) [ci-skip]
Fixes #39920.
Resolves #38329.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
2020-11-01 11:49:29 -06:00
Jonathan Hefner e7b6928704 Edit GS guide § Using Partials to Share View Code [ci-skip]
Fixes #39920.
Resolves #38329.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
2020-11-01 11:49:29 -06:00
Jonathan Hefner 0bf055e5f1 Edit GS guide § Updating an Article [ci-skip]
Fixes #39920.
Resolves #38329.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
Co-Authored-By: Petrik de Heus <petrik@deheus.net>
2020-11-01 11:49:29 -06:00
Jonathan Hefner 9de4d98c60 Add GS guide § Finishing Up (Creating) [ci-skip]
Fixes #39920.
Resolves #38328.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
2020-11-01 11:49:29 -06:00
Jonathan Hefner fdca84c63f Edit GS guide § Validations and Error Messages [ci-skip]
Fixes #39920.
Resolves #38328.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
Co-Authored-By: Tasos Latsas <tlatsas2000@gmail.com>
2020-11-01 11:49:29 -06:00
Eugene Kenny a484bd807e Avoid chdir error in bin/setup test on Ruby master
Followup to ae5ecfe26c.

`db:drop` was failing, but the test passed due to `allow_failure: true`.
2020-11-01 16:58:22 +00:00
Tomer Brisker 1bc7cce8fe
Reduce object allocations in param wrapping
When wrapping parameters, `_extract_parameters` is called twice for
every request. In most cases, both the `include` and `exclude` options
will be empty. In that case, we can use a logical check to save
allocation of an empty array and another allocation of a new array
concatenating the empty array with the hard-coded `EXCLUDE_PARAMETERS`.
The result is 4 array allocations less per request when wrapping is
enabled and `exclude` is not set.
2020-11-01 15:07:03 +02:00
Eugene Kenny de0f59f1ce
Merge pull request #38261 from vipulnsward/wrapper-support-alias-attrs
Adds support to wrap aliased attributed in object hash in params wrapper
2020-11-01 12:42:37 +00:00
Eugene Kenny fcd40a443a Raise database error when table doesn't exist
Since 1944a7e74c, adding a foreign key or
check constraint to a non-existent table results in an unhelpful error:

    NoMethodError: undefined method `scan' for nil:NilClass

This restores the previous behaviour of raising the underlying error
from the database, which describes the actual problem.
2020-11-01 12:31:39 +00:00
Kasper Timm Hansen afb9145a59
Merge pull request #40499 from seanpdoyle/aria-omit-empty
ARIA attributes: serialize empty Hash and Array as nil
2020-11-01 01:09:07 +01:00
Kasper Timm Hansen 0a2f08b158
Merge pull request #40501 from jonathanhefner/guides-irb-code-copy-button
Fix copy button for IRB code examples [ci-skip]
2020-11-01 01:03:02 +01:00
Kasper Timm Hansen 37842ad7c6
Merge pull request #40502 from jonathanhefner/guides-irb-code-triple-click
Fix triple-click-to-select for IRB code examples [ci-skip]
2020-11-01 01:01:21 +01:00
Jonathan Hefner 0d04178c81 Edit GS guide § Using Strong Parameters [ci-skip]
Fixes #39920.
Resolves #38328.

Co-Authored-By: Ryan Bigg <me@ryanbigg.com>
2020-10-31 17:11:31 -05:00