Commit Graph

852 Commits

Author SHA1 Message Date
Deepak Mahakale
306d99f8ca
Add changelog for the new internal route rails/info/notes 2024-06-13 17:14:37 +00:00
Earlopain
d56adb8d56 Changelog tweak for lazy routes
Adds context to the changelog that eager-loaded envs will draw routes
eagerly like they did previously.
2024-06-06 11:37:31 -05:00
Gannon McGibbon
7ac333858c Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-06-04 11:12:12 -05:00
Chris Oliver
7594a73942
Add rubocop and GitHub Actions to plugin generator
When creating new Rails plugins, rubocop and GitHub Actions are now
included to make linting and testing easier.
2024-05-18 09:19:12 -05:00
Jean Boussier
33f6c49118 Appease the linter 2024-05-14 15:19:03 +09:00
David Heinemeier Hansson
bee3fa41ca
Add Kamal by default to Rails 8 (#51798)
* Add Kamal by default
2024-05-13 17:32:42 -07:00
Rafael Mendonça França
a4d58ddea7
This will be released in 7.2 2024-05-13 18:20:53 +00:00
Andrew Novoselac
5b91084f20 Remove support for oracle, sqlserver and JRuby specific database adapters from the new and db:system:change commands. The supported options are sqlite3, mysql, postgresql and trilogy. 2024-05-13 14:07:47 -04:00
Rafael Mendonça França
bf59d363fb
Clean CHANGELOG for 8.0 2024-05-13 16:55:52 +00:00
Rafael Mendonça França
37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00:00
Gannon McGibbon
e54f869e43 Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-05-08 23:43:06 -04:00
Étienne Barrié
d379fae6d2 Add runtime options from Thor::Actions to app:update 2024-05-02 16:53:21 +02:00
Stan Lo
4c1f7d8328
Register Rails console commands/helpers with its latest extension APIs
This will greatly increase the visibility of Rails console commands and helpers,
and stop rely on IRB's internal components.

Extension API reference: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md

And because we need to create new classes to use the new APIs, I also
moved all the IRB-specific code to a new file, `irb_console.rb`.

Use IRB.conf[:BACKTRACE_FILTER] for backtrace filtering in console

This change uses the new `IRB.conf[:BACKTRACE_FILTER]` to inject the backtrace
filtering logic into IRB. This avoids the need to patch IRB's internal
WorkSpace class.

Update changelog
2024-05-01 22:14:53 +00:00
Rafael Mendonça França
b35df004fd
Remove deprecated Rails::Generators::Testing::Behaviour 2024-05-01 20:19:21 +00:00
Rafael Mendonça França
5085daf98e
Remove deprecated find_cmd_and_exec console helper 2024-05-01 18:46:08 +00:00
Rafael Mendonça França
e38dfb2149
Remove deprecated Rails.config.enable_dependency_loading 2024-05-01 18:46:07 +00:00
Rafael Mendonça França
0c76f17f2d
Remove deprecated Rails.application.secrets 2024-05-01 18:46:04 +00:00
Stan Lo
7254549dcd
Add require: "debug/prelude" after debug's Gemfile entry
In https://github.com/ruby/debug/issues/797, we found that requiring
`debug` automatically activates it, which could introduce runtime overhead
and cause memory bloat. And I think many users aren't aware of this and
could be taxed by this unnecessarily (e.g. having longer builds on CI).

Therefore, I propose to add `require: "debug/prelude"` after `debug`'s
Gemfile entry in the default Gemfile template. This way, users can
still use breakpoint methods like `debugger`, `binding.break`, and `binding.b`,
but the debugger won't be activated until a breakpoint is hit.
2024-04-30 18:59:33 +01:00
Andrew Novoselac
bc9c66583e Allow Actionable Errors encountered when running tests to be retried.
If running in an interactive console, the user will be given the option to correct the error and re-run the tests.

Co-authored-by: Gannon McGibbon <gannon.mcgibbon@gmail.com>
2024-04-03 19:32:34 -04:00
Steve Polito
7242fd7f5c
Conditionally skip test job in ci.yml (#51289)
Skip generating a `test` job in ci.yml when a new application is
generated with the `--skip-test` option.

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-03-25 13:55:20 -07:00
Steve Polito
0f18fe1322 Bump NODE_LTS_VERSION to 20.11.1
In e8638c9a942e94f097dc8f37a3b58ac067a5ca16 we introduced a constant to
store the version of Node to be used when generating `.node-version`.

Since then, the [current LTS][LTS] version of Node is now `20.11.1` as
of [2024-02-14][date].

[LTS]: https://nodejs.github.io/nodejs.dev/en/about/releases/
[date]: https://nodejs.org/en/blog/release/v20.11.1
2024-03-25 05:27:49 -04:00
Mike Dalessio
8957ba58d5
Fix sanitizer vendor config with 7.1 defaults
rails-html-santizer is a dependency of Action View and a transitive
dependency of Action Text (via Action Pack), but may not be loaded
until after railties sets configuration defaults.

This change `require`s rails-html-sanitizer immediately before it's
needed, and avoids the possibly-incorrect assumption that
Rails::HTML::Sanitizer is already defined.

Closes #51246

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-03-06 16:54:16 -05:00
Steve Polito
59a3dd4729
Set action_mailer.default_url_options values in development and test (#51191)
* Set `action_mailer.default_url_options` values in `development` and `test`.

Prior to this commit, new Rails applications would raise
`ActionView::Template::Error` if a mailer included a url built with a
`*_path` helper.

Since we already know [new apps will be served on `localhost:3000`][new
apps], we set this as the value in `development`.

In an effort to remain consistent with existing patters, we set the
`host` to `www.example.com` in `test.

[new apps]: 47300002db/README.md (L81)

* Update railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

---------

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-02-27 16:19:23 -05:00
Steve Polito
fb16702fee Introduce Rails::Generators::Testing::Assertions#assert_initializer
Compliments the existing [initializer][] generator action.

```rb
assert_initializer "mail_interceptors.rb"
```

[initializer]: https://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-initializer
2024-02-23 10:54:25 -05:00
Andrew Novoselac
c90a8701e5
Generate a .devcontainer folder and its contents when creating a new app.
The .devcontainer folder includes everything needed to boot the app and do development in a remote container.

The container setup includes:
 - A redis container for Kredis, ActionCable etc.
 - A database (SQLite, Postgres, MySQL or MariaDB)
 - A Headless chrome container for system tests
 - Active Storage configured to use the local disk and with preview features working

If any of these options are skipped in the app setup they will not be included in the container configuration.

These files can be skipped using the `--no-devcontainer` option.

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-02-14 20:59:48 +00:00
Andrew Novoselac
30506d2ef3
Devcontainers: Introduce SystemTestCase#served_by
When working in a devcontainer, for system tests we need to manually set the host and port serving the application. Let's introduce a method for this, so we don't have to expose the implementation details of Capybara to the developer.

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-02-14 20:58:57 +00:00
Rafael Mendonça França
707b5cb606
Revert "Merge pull request #49360 from skipkayhil/hm-gemfile-ruby-file"
This reverts commit 6985c3bedf0d85c180d8b86a2fcd6b19e7251bd3, reversing
changes made to 3163bb735189eddd7c152a1e72bed7b4d052f7d4.

Reason: While we want to apply this change, it make bundle being more
strict about the ruby version. This is particularly problematic for
the devcontainer images that don't support defining which patch
version of ruby to install.

Right now, you can only say you want Ruby 3.2, which could mean
3.2.3 or 3.2.0. If for some reason the devcontainer image doesn't
match the patch version on `.ruby-version` it will fail to install.

We are planning to solve this problem by publishing our own
ruby images that allow defining the patch level, but until that
we can't apply this change.
2024-02-14 20:53:47 +00:00
Hartley McGuire
a1c6e27baf
Use ruby file: ".ruby-version" for new apps
Previously, new apps would have a Ruby version set in both the Gemfile
and the .ruby-version file. This duplication makes it more difficult to
quickly change an application's ruby version as users must remember to
update multiple files.

This commit updates the app generator's Gemfile to read the Ruby version
from the .ruby-version file. Since this feature was introduced in the
latest version of Bundler, it will only be enabled if a supported version
of Bundler is used.

Alternatively, another solution mentioned on the original PR adding
.ruby-version was that the .ruby-version file could be removed once
rvm/rbenv support reading the Ruby version from the Gemfile. This has a
downside that many other tools like chruby do not have plans to support
reading a Ruby version from the Gemfile, and so users of those tools
would have a worse experience if the .ruby-version file is removed.

Co-authored-by: Takumi Shotoku <sinsoku.listy@gmail.com>
2024-02-14 12:28:31 -05:00
Edouard CHIN
ce9f13c97e Don't load *_test.rb file from the "fixtures" folder:
- If an application has files named `*_test.rb` in the
  "fixtures/files" folder, they were picked up to be loaded.
  In most cases this would result in a LoadError as its likely
  those files include code that can't be loaded.
2024-02-13 19:01:14 +01:00
KJ Tsanaktsidis
5faeb7007d
Don't pop logger tags in Rails::Rack::Logger until request is finished
At the moment, Rails::Rack::Logger tags the logger (if it's
ActiveSupport::TaggedLogging) for the duration of the @app.call, but
only fires the request.action_dispatch event later, on body close. That
means anything logged in request.action_dispatch handlers won't have the
same tags as the rest of the request.

Fix this by deferring the popping of tags into
finish_request_instrumentation, in the same way that finishing the
instrumentation handle is deferred.
2024-02-07 14:12:07 +11:00
northeastprince
8e98b614e4 Setup jemalloc in default Dockerfile 2024-02-04 10:02:51 +01:00
Willian Tenfen W
35f132e7ee
Support comment symbol '#' on .railsrc file
Commented out lines in .rc file should not be treated as arguments when
using rails new generator command. [Fix #50899]
2024-01-29 17:56:24 +00:00
Ruy R.
4ddf6ccad0
Skip CSS when creating APIs.
Update CHANGELOG.

Address requested changes.
2024-01-29 06:42:01 -03:00
David Jensenius
49e9ec91cd
Revert help on unrecognized bare options 2024-01-25 13:56:37 -05:00
Stan Lo
7cbf06c1e8
Display dev/test env in console prompt in blue instead of green
The combination of red and blue is more color-blind friendly than red
and green.

Discussion: https://github.com/rails/rails/pull/50796#discussion_r1463670198
2024-01-24 11:07:40 +00:00
Stan Lo
09b2aecec5
Change Rails console prompt's format
Following the discussion in #50770, the new format will be:
`[dasherized-app-name]([colorized-env])>`

For example, if the app's module name is `MyApp`, the prompt will be:
`my-app(dev)>`, where the `dev` part will be colored.

Update railties/lib/rails/commands/console/console_command.rb

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>

Update changelog
2024-01-20 23:34:33 +00:00
Stan Lo
0c2898a768
Create IRBConsole to encapsulate IRB-specific setup
Add Rails-specific IRB prompt

Update changelog
2024-01-19 19:01:26 +00:00
Jonathan Hefner
dc85b953aa Print bin/rails help on unrecognized bare options
Prior to this commit, `bin/rails` would pass unrecognized bare options
on to Rake:

  ```console
  $ bin/rails -v
  Rails 7.2.0.alpha

  $ bin/rails -V
  rake, version 13.0.6

  $ bin/rails -s
  Running 0 tests in a single process (parallelization threshold is 50)
  ...

  $ bin/rails -S
  invalid option: -S
  ```

This commit changes `bin/rails` to print its help message when given an
unrecognized bare option:

  ```console
  $ bin/rails -v
  Rails 7.2.0.alpha

  $ bin/rails -V
  Usage:
    bin/rails COMMAND [options]

  You must specify a command. The most common commands are:
  ...

  $ bin/rails -s
  Usage:
    bin/rails COMMAND [options]

  You must specify a command. The most common commands are:
  ...

  $ bin/rails -S
  Usage:
    bin/rails COMMAND [options]

  You must specify a command. The most common commands are:
  ...
  ```

However, for backward compatibility, an exception has been made for the
`-T` / `--tasks` option:

  ```console
  $ bin/rails -T
  # Prints list of Rake tasks...
  ```

Addresses #50712.
2024-01-18 17:43:18 -06:00
Xavier Noria
299900f4e5 Edit pass over the railties CHANGELOG 2024-01-16 20:39:04 +01:00
Takumasa Ochi
23cc9229ff
Ensure only directories exist in Rails default load paths
Previously, some files put under `app` directory would contaminate the load paths.
This commit removes files from the default load paths set up by the Rails framework.

Now, only directories are included as default in the following paths:

* autoload_paths
* autoload_once_paths
* eager_load_paths
* load_paths
2024-01-15 15:04:53 +09:00
Takumasa Ochi
d7e2575082
Prevent unnecessary application reloads in development
Previously, the Rails application would reload due to changes
in some files outside the autoload paths.
For instance, editing `app/README.md` would trigger a reload,
even though the reloaded classes and modules were identical
to those loaded previously.

This commit fixes this issue by ensuring the application reloads correctly
according to `Rails.autoloaders.main.dirs`, thereby preventing unnecessary reloads.

https://github.com/rails/rails/issues/37011#issuecomment-1322560651
2024-01-11 21:35:47 +09:00
TangRufus
4c5b6008ba
Add oven-sh/setup-bun to GitHub CI when generating an app with bun 2024-01-08 19:50:21 +00:00
Hans Schnedlitz
482330d156
Do not generate pidfile in production environments (#50644)
* Remove pidfile in production

* Update changelog

* Update activestorage/test/dummy/config/puma.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update template and other dummy files

---------

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-01-08 14:47:25 -05:00
Adrian
475bb4b1ed default annotate_rendered_view_with_filenames to true in development
remove whitespaces

remove whitespaces
2024-01-04 21:24:37 +02:00
Alex Ghiculescu
957a3e5e55 Add BACKTRACE env variable to turn off backtrace for normal running, not just tests 2024-01-04 07:25:12 +10:00
Sean Doyle
9a58f7eccd Raise ArgumentError when reading from config.x with arguments
The flexibility provided by `config.x` supports arbitrarily defining new
configuration objects on-the-fly. Each new intermediate configuration
object is constructed during chaining from its ancestor through a method
invocation made without arguments.

Conversely, writing to leaf configuration values occurs when the invoked
method's name ends with `=`, and the new configuration value is assigned
to whatever that method's arguments are.

There are no cases when reading from a `config.x` value or building the
intermediate values involves arguments.

Prior to this commit, a read invoked with a method arguments would
ignore those arguments. While this is robust and error-free, it's
possible to obscure misuse.

For example, consider a line like:

```ruby
config.x.my_config.enabled = true
config.x.my_config.enabled #=> true
```

Now consider that first line with a typo that omits the `=`:

```ruby
config.x.my_config.enabled true
config.x.my_config.enabled #=> nil
```

This commit aims to provide more direct feedback for scenarios like the
one above. There aren't legitimate use cases for invoking `#enabled`
with arguments, so raise a `ArgumentError` when encountering a read with
arguments.
2024-01-03 15:08:40 -05:00
David Heinemeier Hansson
bb5e2791e0
Add default pwa manifest and service worker file (#50528)
* Add default pwa manifest and service worker file

* Update CHANGELOG.md
2024-01-03 13:07:12 +01:00
Akhil G Krishnan
9bc4536d47 Add changelog entry for #50512 2024-01-01 09:35:54 +05:30
David Heinemeier Hansson
08a792be84
Default to creating GitHub CI files (#50508)
* Default to creating GitHub CI files
2024-01-01 00:37:12 +01:00
Vipul A M
813afbdd74
Add brakeman to new Rails applications (#50507)
It can be skipped with the `--skip-brakeman` flag.

Closes #50501
2023-12-31 19:09:47 +01:00