Commit Graph

83639 Commits

Author SHA1 Message Date
Steven Harman 3b012a5254
Respect the formatter keyword arg on init
The stdlib Logger::new allows passing a :formatter keyword argument to
set the logger's formatter. ActiveSupport::Logger::new ignores this
argument by always setting the formatter to an instance of
SimpleFormatter. Instead, we should only set it when none is yet set.
2022-04-22 19:55:36 -04:00
Nícolas Iensen 3ab4a9d75b Add --name option to the app generator
In this commit, we are adding the option to set the name of the app
when generating a new one with `rails new`.

The option `--name` will override the application name to be different
from the folder name.

```
rails new my-app-folder --name=my-actual-app-name"
```

The command above will generate a
new Rails application in the folder `my-app-folder`, but the file
`config/application.rb` would have the following structure:

module MyActualAppName
  class Application < Rails::Application
  end
end

This option would be most useful when generating a Rails application in
the current folder:

```
rails new . --name=my-app
```
2022-04-22 23:22:45 +00:00
fatkodima bfda311f8c Add missing require of `action_controller/metal/exceptions` to `action_controller` 2022-04-22 19:34:25 +03:00
Carlos Antonio da Silva b925880914 Expose request method to reset the CSRF token
We already have a commit CSRF method exposed via the request object
since it's used by the implementation when committing the session, so
having a similar reset CSRF method exposed makes sense, and hides some
of the internal complexity of calling that method via the controller
instance.

It will also facilitate reaching out to the reset CSRF logic from other
libraries like Devise, to more easily integrate with this change.
2022-04-22 11:57:42 -03:00
Dorian Marié 1be896a12c
Updates --skip-git option description to be more accurate
It skips git init, .gitignore and .gitattributes not only .gitignore
2022-04-22 16:39:35 +02:00
Petrik dc9c7cf1fa Update sdoc to 2.3.2 to support latest rdoc 2022-04-22 10:04:34 +02:00
Jonathan Hefner bc9fa030a6
Merge pull request #44928 from gumatias/patch-1
Add missing info for `change` column and table comment in Guides [ci-skip]
2022-04-21 19:02:23 -05:00
Gustavo Matias dos Santos e2ffa66256 Add info for `change` column and table comment
This will ensure the guide is aligned with the doc on some things that I believe it's useful. Some folks do go for the guides more of than the api for a quick reference.

Order alphabetically

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Add change colum and table comment links for reference in guide

Update  working so we know this list may keep changing
2022-04-21 15:40:37 -07:00
Junichi Sato 5c89dc3eb9
Syntax highlight ruby code in multi db guide (#44929) 2022-04-21 20:01:38 +05:30
Eileen M. Uchitelle c9e9ed77f4
Merge pull request #44927 from andreimaxim/fix-jdom-on-jruby-93xx
Fix ActiveSupport::XmlMini on JRuby 9.3.x.x
2022-04-21 07:28:47 +01:00
Andrei Maxim dd851f3584
Access JDOM fields as constants in order to be compatibile with JRuby 9.3.x.x 2022-04-21 05:33:59 +03:00
Jonathan Hefner 8ace32c4cc
Merge pull request #44911 from pocke/Remove_unnecessary_note_for_primary_key_in_the_guide
Remove unnecessary note for primary_key in the guide [ci-skip]
2022-04-18 10:08:15 -05:00
Jonathan Hefner 3c6da6a610
Merge pull request #44913 from pocke/_guide__Enable_syntax_highlight_for_a_code_in_AR_validation_guide
[guide] Enable syntax highlight for a code in AR validation guide [ci-skip]
2022-04-18 09:33:37 -05:00
Masataka Pocke Kuwabara c280c5d4d9 [guide] Enable syntax highlight for a code in AR validation guide 2022-04-18 23:28:03 +09:00
Masataka Pocke Kuwabara 70a0754e5d Remove unnecessary note for primary_key in the guide 2022-04-18 10:57:33 +09:00
Jonathan Hefner 2f66df0e10 Avoid escaping paths when editing credentials
`Shellwords.escape` escapes unquoted spaces with a backslash, but
Windows does not treat backslash as an escape character.  Escaping is
also a problem when paths are expressed in shortened 8.3 format (e.g.
`C:\Users\RubyOn~1\AppData\Local\Temp\...`) because a backslash will be
erroneously added before the `~`.

We can avoid the need to escape by using `system(command_name, *args)`
instead of `system(command_line)`, but we must still support
`ENV["EDITOR"]` values that embed command line arguments, such as
`subl -w`.

This commit changes to `system(command_name, *args)`, but uses
`Shellwords.split` to extract any embedded arguments from
`ENV["EDITOR"]`.  This requires that Windows users put quotes around the
entire path of their editor if it contains spaces, such as:

```
SET EDITOR="C:\Program Files\Microsoft VS Code\Code.exe" -w
```

In other words, the following are **not** supported on Windows:

```
SET "EDITOR=C:\Program Files\Microsoft VS Code\Code.exe"
SET EDITOR=C:\Program Files\Microsoft VS Code\Code.exe
SET EDITOR=C:\"Program Files"\"Microsoft VS Code"\Code.exe -w
SET EDITOR=C:\Program^ Files\Microsoft^ VS^ Code\Code.exe -w
SET EDITOR=C:\Program` Files\Microsoft` VS` Code\Code.exe -w
```

Fixes #41617 (again).
Closes #44890.
2022-04-17 11:17:04 -05:00
Xavier Noria e3f54144d8 Register the interlock hook only if reloading
If reloading is enabled, we need the interlock to synchronize reloads.

If reloading is disabled and so is eager loading, in the past you still needed
to synchronize autoloads because `classic` was not thread-safe. With Zeitwerk,
this is no longer needed.
2022-04-15 12:57:35 +02:00
Ryuta Kamizono c9e5057de4
Merge pull request #44900 from fatkodima/check_constraints-pg-schemas
Scope PostgreSQL check constraints to current schemas
2022-04-15 08:33:14 +09:00
fatkodima cc8637dcef Scope PostgreSQL check constraints to current schemas 2022-04-14 23:43:40 +03:00
Xavier Noria cbfe735c69 Deprecate config.enable_dependency_loading 2022-04-14 22:31:26 +02:00
Jonathan Hefner cdabe88d98
Merge pull request #44893 from ghousemohamed/add-docs-for-run-load-hooks
Add API docs for `run_load_hooks` [ci-skip]
2022-04-14 11:42:59 -05:00
Xavier Noria c05fcc74ff
Merge pull request #44870 from rails/config.reload
Define config.reload to be !config.cache_classes
2022-04-14 18:36:48 +02:00
Xavier Noria 2953ae5c8a Define config.enable_reloading to be !config.cache_classes
Every time I write `config.cache_classes` I have to pause for a moment to make
sure I get it right. It makes you think.

On the other hand, if you read `config.enable_reloading = true`, does the
application reload? You do not need to spend 1 cycle of brain CPU to nod.
2022-04-14 18:11:36 +02:00
Ghouse Mohamed 6a71188f9c Add API docs for run_load_hooks 2022-04-14 21:39:14 +05:30
Claas Z def782dfeb
Clarified requirements for keys in nested structures 2022-04-14 17:50:05 +02:00
Jean Boussier e5b08b9ebc Replace `async: true` parameter by `async_*` methods 2022-04-14 09:55:24 +02:00
Jean Boussier 03e435b943 PoC: Active Record API for general async queries
Followup: https://github.com/rails/rails/pull/41372

Something we knew we'd need when we implemented `Relation#load_async`
but that we chose to delay to have time to think about it.

Right now, Active Record async support is limited to "collection results",
but among the not so fast queries that would benefit from asynchronicity
you often find aggregates (e.g. `count`, `sum`, etc) as well as hand crafted
`find_by_sql` queries.

`load_async` was easy to add as an API, because `Relation` acts as a collection
so it was trivial to simply block whenever it was iterated while retaining total
API compatibility.

For aggregates and `find_by_sql`, we have no other choice but to return something
different in async mode, with its own API.

This proof of concept showcase what this API looks like for `Relation#count`:

```ruby
Post.where(published: true).count # => 2
promise = Post.where(published: true).count(async: true) # => #<ActiveRecord::Promise status=pending>
promise.value # => 2
```

This API should be applicable to all aggregate methods, as well as all methods
returning a single record, or anything other than a `Relation`.
2022-04-14 09:53:54 +02:00
Jonathan Hefner 51b4370bb3
Merge pull request #44871 from timchaston/fix-broken-link-for-redis-pub-sub-in-action-cable-overview
Fix broken link for Redis PubSub in 'Action Cable Overview' guide [ci-skip]
2022-04-13 09:44:44 -05:00
Eileen M. Uchitelle ebf6498021
Merge pull request #44887 from fatkodima/rotate-debug_log
Rotate the debug.log on each 100MB
2022-04-13 10:04:01 -04:00
Xavier Noria 9fb131cb39 Move misplaced conditional 2022-04-13 15:58:36 +02:00
Eileen M. Uchitelle a0eaaae0d5
Merge pull request #44285 from fatkodima/fix-test-env-schema-dump-false
Fix handling disabled schema dumping for test environment
2022-04-13 09:06:23 -04:00
fatkodima 7159f5b879 Rotate the debug.log on each 100MB 2022-04-13 15:38:19 +03:00
Ryuta Kamizono 6bb0e0efb2
Merge pull request #44872 from entretechno/utc-12
Update ActiveSupport time zone tests for UTC-12 (International Date Line West)
2022-04-13 17:52:23 +09:00
Ryuta Kamizono 7724704df0
Merge pull request #44883 from yahonda/blade_073_for_ruby32
Use blade 0.7.3 to support Ruby 3.2
2022-04-13 16:14:40 +09:00
Ryuta Kamizono d17aa6ad49
Merge pull request #44882 from SkipKayhil/fix-eager-undefined-warning
fix warnings when eager loading on ruby 2.7
2022-04-13 16:12:36 +09:00
Hartley McGuire afce06bdb2
fix warnings when eager loading on ruby 2.7
before:

```
ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib
-I../actionview/lib -I../activemodel/lib
test/application/loading_test.rb

Run options: --seed 11862

............/home/hartley/dev/github.com/skipkayhil/rails/activesupport/lib/active_support/dependencies/autoload.rb:75:
warning: instance variable @_eagerloaded_constants not initialized
/home/hartley/dev/github.com/skipkayhil/rails/activesupport/lib/active_support/dependencies/autoload.rb:75:
warning: instance variable @_eagerloaded_constants not initialized
.../home/hartley/dev/github.com/skipkayhil/rails/activesupport/lib/active_support/dependencies/autoload.rb:75:
warning: instance variable @_eagerloaded_constants not initialized
/home/hartley/dev/github.com/skipkayhil/rails/activesupport/lib/active_support/dependencies/autoload.rb:75:
warning: instance variable @_eagerloaded_constants not initialized
/home/hartley/dev/github.com/skipkayhil/rails/activesupport/lib/active_support/dependencies/autoload.rb:75:
warning: instance variable @_eagerloaded_constants not initialized
...

Finished in 2.819071s, 6.3851 runs/s, 13.1249 assertions/s.
18 runs, 37 assertions, 0 failures, 0 errors, 0 skips
```

after:

```
ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib
-I../actionview/lib -I../activemodel/lib
test/application/loading_test.rb

Run options: --seed 34841

..................

Finished in 3.407082s, 5.2831 runs/s, 10.8597 assertions/s.
18 runs, 37 assertions, 0 failures, 0 errors, 0 skips
```
2022-04-12 23:51:34 -04:00
Yasuo Honda 75d104fbb0 Use blade 0.7.3 to support Ruby 3.2
blade 0.7.3 includes https://github.com/javan/blade/pull/12

Related to https://github.com/rails/rails/pull/44152
18e3226c9b
2022-04-13 08:31:38 +09:00
fatkodima 9a4904d7d3 Fix handling disabled schema dumping for test environment 2022-04-13 00:11:25 +03:00
Xavier Noria fa6c75be32 Fixes style 2022-04-12 19:58:22 +02:00
Xavier Noria 73f306a4bb Eager load after reload, if enabled
Fixes #24819
2022-04-12 19:54:53 +02:00
Jonathan Hefner fdf840f69a
Merge pull request #44865 from entretechno/guides-locale-errors
Remove no-longer-relevant `activerecord` locale namespace in example in guides [ci-skip]
2022-04-11 17:45:16 -05:00
Jeremiah 9af580d50e Remove `activerecord` namespace from example, since it no longer returns the value shown below 2022-04-11 17:41:44 -05:00
Jonathan Hefner 255accb0a5 Fix button_to UJS examples formatting [ci-skip]
Because the indented code block follows an indented list item, RDoc
interprets the examples as a continuation of the list item prose,
instead of code.  To distinguish the two, this commit moves the examples
to their own subsection with an intervening subheading.

Additionally, this commit applies a few other formatting tweaks.
2022-04-11 15:35:58 -05:00
Tim Chaston 65946d7eb5 Update URL for Redis Pub/Sub documentation. Change text of link to Redis Pub/Sub documenation to include a slash, to reflect the title on that page. 2022-04-12 06:35:41 +10:00
Jonathan Hefner 7ad1bc8845 Fix link_to UJS examples formatting [ci-skip]
Because the indented code block follows an indented list item, RDoc
interprets the examples as a continuation of the list item prose,
instead of code.  To distinguish the two, this commit moves the examples
to their own subsection with an intervening subheading.

Additionally, this commit applies a few other formatting tweaks.
2022-04-11 15:35:24 -05:00
Jonathan Hefner eea6f4dc81
Merge pull request #44784 from ghiculescu/data-remote-no-turbo
Document that `data-remote` and `data-method` are deprecated [ci-skip]
2022-04-11 15:27:35 -05:00
Alex Ghiculescu be746b2623 Document that `data-remote` and `data-method` are deprecated
Follow up to https://github.com/rails/rails/pull/43112 and https://github.com/rails/rails/pull/44100

- `data-remote` is deprecated on links and buttons. Turbo doesn't need it since that is the default behaviour. You use `data-turbo=false` on elements that opt out of that, but I don't think that's in scope for Rails.
- `data-method` is deprecated on links. Turbo expects [data-turbo-method](https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method).

Update actionview/lib/action_view/helpers/url_helper.rb

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

Update actionview/lib/action_view/helpers/url_helper.rb

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2022-04-11 13:03:14 -05:00
Jonathan Hefner 98b8b0dd70
Merge pull request #44862 from jackscotti/patch-1
Update source of `secret_key_base` in cookie rotator example [ci-skip]
2022-04-11 09:36:27 -05:00
Jeremiah c75f94ab83 Update ActiveSupport time zone tests for UTC-12 (International Date Line West) 2022-04-11 09:35:41 -05:00
Jonathan Hefner 81f61cadb3
Merge pull request #44869 from ShaneBoyer/patch-1
fix: config.host_authorization reference [ci-skip]
2022-04-11 08:17:10 -05:00