Commit Graph

7629 Commits

Author SHA1 Message Date
Jean Boussier
2a3a6e5efc Improve rails s error message when no server could be found.
Fix: https://github.com/rails/rails/issues/45092

Up until 3.0, `rails s` would always at least find webrick. But since it
was removed in Ruby 3.0, it's now possible to end up with no available server
at all.

In such case we should recommend adding puma to the Gemfile.
2022-05-14 09:43:34 -04:00
Dorian Marié
7b244c99f6 Add --js and --skip-javascript options to rails new`
`--js` alias to `rails new --javascript ...`

Same as `-j`, e.g. `rails new --js esbuild ...`

`--skip-js` alias to `rails new --skip-javascript ...`

Same as `-J`, e.g. `rails new --skip-js ...`
2022-05-13 22:36:36 +02:00
Shouichi Kamiya
44b56fba20 Fix rails test command to handle leading dot slash
Co-authored-by: oljfte <oljfte@gmail.com>
2022-05-13 19:59:10 +09:00
Petrik
55073ac10f Use the CSS badge for the API docs as well
Sdoc 2.4.0 supports a CSS badge that can be set by passing the version
as the HORO_BADGE_VERSION env variable.

The old badge image can be removed, as it no longer needs to be copied
by the docs server: https://github.com/rails/rails-docs-server/pull/28
2022-05-10 21:05:59 +02:00
Masataka Pocke Kuwabara
0768e83492 Add anchor to a link in load_defaults's api guide [ci-skip] 2022-05-09 17:29:28 +09:00
Jean Boussier
38d5846e06
Merge pull request #44910 from jonathanhefner/credentials-avoid-escaping-paths
Avoid escaping paths when editing credentials
2022-05-09 10:11:39 +02:00
Jonathan Hefner
4d92e965ef Remove dead URL
The `rubysl/rubysl-yaml` repo and its issue tracker are gone, and there
doesn't seem to be an alternative URL.
2022-04-29 13:47:51 -05:00
Aaron Patterson
89471b2d7d
Merge pull request #44941 from nicolasiensen/add-name-option-to-app-generator
Add --name option to the app generator
2022-04-28 12:52:53 -07:00
Baoshuo Ren
95253b2582
chore: remove git.io
see: https://github.blog/changelog/2022-04-25-git-io-deprecation/
2022-04-26 21:01:32 +08:00
Eileen M. Uchitelle
8ff748b32f
Merge pull request #44935 from dorianmariefr/patch-1
Updates --skip-git option description to be more accurate
2022-04-25 16:37:14 -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
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
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
Xavier Noria
cbfe735c69 Deprecate config.enable_dependency_loading 2022-04-14 22:31:26 +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
Xavier Noria
9fb131cb39 Move misplaced conditional 2022-04-13 15:58:36 +02:00
Xavier Noria
73f306a4bb Eager load after reload, if enabled
Fixes #24819
2022-04-12 19:54:53 +02:00
Aaron Patterson
cfa7284789
Merge pull request #44826 from stefkin/acp-eql-flag
Add a flag to disable deprecated AC::Parameters comparison
2022-04-04 09:09:44 -07:00
eileencodes
ad52c0a197
Remove legacy_connection_handling
This functionality has been deprecated since Rails 6.1 and can now be
removed. I've deleted all code, docs, references, and tests related to
this feature.
2022-04-04 09:36:13 -04:00
Seva Stefkin
67762c2407
Add a flag to disable deprecated AC::Parameters comparison 2022-04-04 10:08:05 +02:00
Gannon McGibbon
dfd0c9e5bd
Merge pull request #44717 from duduribeiro/add-js-dependencies-setup-when-not-using-importmaps
Add yarn install into bin/setup when not using importmap
2022-03-28 15:34:17 -04:00
Cadu Ribeiro
155b7570fa Add yarn install into bin/setup when not using importmap
After af7428c4acd0fcf9eed5c7215856594a078f23b7 the yarn install
instructions was dropped from bin/setup. This commmit adds it into
the setup script again if the user is not using importmap.
2022-03-28 15:50:28 -03:00
Gannon McGibbon
d38ed8bf0d
Merge pull request #44781 from ghousemohamed/added-missing-session-store-to-docs
Added missing `config.session_store` option `:cache_store` to docs [ci-skip]
2022-03-28 14:22:24 -04:00
Ghouse Mohamed
f5a79cc197 Added missing config.session_store option to docs 2022-03-28 19:17:16 +05:30
Rafael Mendonça França
af0733a8e7
Make sure respond_to? and method_missing works in abstract Railties
Those methods were raising an confusing exception when trying to call
`Rails::Railtie.respond_to?(:something)`. Now they just work.

Fixes #44761
2022-03-25 23:56:34 +00:00
Ghouse Mohamed
d5257887da Removed code which sets host! in console mode as it is not needed 2022-03-23 02:59:52 +05:30
Xavier Noria
7d87086f10 Reset current scopes in AR using an on_unload callback
Rails 6.0 and Rails 6.1 didn't support the undocumented `before_remove_const` in
`zeitwerk` mode. I noticed this cleanup in AR was not being executed, and
restored the original code for Rails 7.

However, invoking `respond_to?` in an `on_unload` callback may have unexpected
side-effects, as seen in #44125. So, this patch reimplements the cleanup in a
more modern way.

Fixes #44125.
2022-03-20 21:41:08 +01:00
Rafael Mendonça França
5c1bd20f0d
Merge pull request #44693 from ghousemohamed/fix-docs-related-gem-versions
Fix `#version` method docs and some typos [ci-skip]
2022-03-15 16:28:07 -04:00
Ghouse Mohamed
6ee6cb554b Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
Hartley McGuire
1faf619813 remove extra core_ext/object/blank requires
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
- usage added in 64fd666
- unneeded because of active_support/rails: 8f58d6e

railties/lib/rails/rack/logger.rb
- usage added in c83d9a1
- usage removed in c131211

activesupport/lib/active_support/number_helper/number_converter.rb
- the NumberHelper was split into multiple classes in 2da9d67, however
  the require was left in NumberConverter even though
  NumberToPhoneConverter is the only class where it's used

activesupport/lib/active_support/duration/iso8601_serializer.rb
- usage added in 04c512d
- usage removed in 51e991f
2022-03-14 21:58:10 -04:00
Andrew White
7f5b3e04c8
Use controller_class_path in NamedBase#route_url
The `route_url` method now returns the correct path when generating
a namespaced controller with a top-level model using `--model-name`.

Fixes #44662.
2022-03-12 09:45:10 +00:00
Breno Gazzola
c744439631 Do not remove assets initializer when using propshaft 2022-03-04 14:43:29 -03:00
Rafael Mendonça França
e3353e53c9
Merge pull request #44495 from Edouard-chin/ec-integration-test-inspect
Don't output the whole Rails::Railtie object when a NoMethodError is raised
2022-03-01 23:31:17 -05:00
Aaron Patterson
ea9f0103fd
Revert "Revert "Merge pull request #42843 from buckley-w-david/message-verifier-default-serializer""
This reverts commit fd4e63cc28863b9d1b7cca2da80bb0b1e879c2d3.
2022-03-01 15:14:43 -08:00
Aaron Patterson
fd4e63cc28
Revert "Merge pull request #42843 from buckley-w-david/message-verifier-default-serializer"
This reverts commit a40d7815ac92c3d24a7e0fab9a4f487860937ec7, reversing
changes made to ad2529be4b5942b6f38ab83b9796e1976685edca.
2022-03-01 13:58:40 -08:00
Saba Kiaei
5256c90327 Switch ActiveSupport::MessageVerifier's default serialization to JSON 2022-03-01 13:02:17 -05:00
Edouard CHIN
e60dd826c0 Don't output the whole Rails::Railtie object
- ### Summary

  The terminal output on a Rails application running ruby 3 will be
  cluttered with thousands of lines if one inadventarly call a
  unexisting method.
  This happen in various places (IntegrationTest, when running a db
  migration ...).
  This is related to a change in ruby 3 when a NoMethodError is
  raised.

  ### Simple reproduction

  ```
  class A
    def initialize(session)
      @a = session
    end
  end

  test = A.new("*" * 36)
  test.dsad # undefined method `dsad' for #<A:0x00007f847d8494b0 @a="************************************"> (NoMethodError)
  # Note that the "#<A:0x00007f847d8494b0 @a="************************************">" part
  # is 65 chars long.

  test = test = A.new("*" * 37)
  test.dsad # undefined method `dsad' for #<A:0x00007fa8c38299c0> (NoMethodError)
  ```

  On Ruby < 3, the NoMethodError message (everything starting from the
  "#" char) could only be 65 characters long. If it was above that
  ruby would only output the name of the class and its address.

  On Ruby >= 3, that limitation has been removed and the message can
  be any length long.

  ### On Rails

  Anytime a method is called on a object that holds the entire
  Rails::Application, the terminal would output the entire application
  which is annoying be can be dangerous because it will leak
  everything containing the credentials (stored inside the Application
  object).
2022-02-28 20:27:07 +01:00
Rafael Mendonça França
fec53a141a
Merge pull request #44488 from p8/railties/csp-initializer-copy
Correct CSP initializer copy
2022-02-25 15:43:06 -05:00
John Hawthorn
0a44c3f90b
Merge pull request #44454 from jhawthorn/rack_logger_finish_with_state
Use finish_with_state inside Rack::Logger
2022-02-24 15:24:55 -08:00
Eileen M. Uchitelle
be4b9057bb
Merge pull request #44504 from sanjioh/fix-typos
Fix some typos
2022-02-23 16:58:06 -05:00
Jonathan Hefner
497ab719d0
Merge pull request #44509 from jonathanhefner/apidocs-cross-link-docs
Cross-link API docs [ci-skip]
2022-02-23 12:08:41 -06:00
Jonathan Hefner
840ecf1e96
Merge pull request #44508 from jonathanhefner/apidocs-format-application-booting-process
Fix formatting of "Booting process" section [ci-skip]
2022-02-23 12:07:56 -06:00
Hartley McGuire
67b9347c16 use git init -b in generator when supported
This has the benefit of hiding the warning message from git when
initialBranch configuration is unset, and was a recommendation on the
original commit adding main as the default branch for generators.

Ref: eb261937ac856100b4e1c8a2dbb56aab6e5d140e
2022-02-22 11:05:46 -05:00
Petrik
ba3ff2def8 Improve CSP initializer copy
The `content_security_policy_report_only` config does not enable
violation reporting.
It makes sure the policy isn't enforced, only reported.

Also link to the guide instead of external documentation.
2022-02-21 21:14:34 +01:00
Jonathan Hefner
a199aaedb8 Cross-link API docs [ci-skip]
RDoc will automatically format and link API references as long as they
are not already marked up as inline code.

This commit removes markup from various API references so that those
references will link to the relevant API docs.
2022-02-21 11:45:25 -06:00
Jonathan Hefner
fe3fc94eb0 Fix formatting of "Booting process" section [ci-skip]
Rendering the list of boot steps as a code block confused the syntax
highlighter.

This commit changes the list to use RDoc's ordered list syntax, and adds
inline code markup as appropriate.
2022-02-21 11:45:19 -06:00
Jonathan Hefner
a801aa7cde Mark up inline code [ci-skip] 2022-02-21 11:11:11 -06:00
Jonathan Hefner
e37adfed4e Add Oxford commas [ci-skip] 2022-02-21 11:11:11 -06:00
Jonathan Hefner
5fdbd217d1 Fix typos [ci-skip] 2022-02-21 11:11:11 -06:00