* Dockerfile binfile fixups; primarily for Windows users
* chmod +x
* CRLF => LF
* ruby.exe => ruby
If Rails new is run on a MacOS or Linux machine, no fixups are
required or emitted to the Dockerfile.
* attempt to placate rubocop
* use binstub
* Add a default health controller
Load balancers and uptime monitors all need a basic endpoint to tell whether the app is up. Here's a good starting point that'll work in many situations.
* Add CHANGELOG entry
* Add test for HealthController
* Account for new default route
* Change dockerfile from using Node 19 to match dev environment
This is accomplished via installing volta: https://volta.sh/.
Also:
* decouple the installation of libvips from node
* add installation of the node_modules by running yarn
This pull request is part one of many intended to add features
from fly.io's generated Dockerfiles that are of general interest
to Rails. For the overall plan, see:
https://community.fly.io/t/preparations-for-rails-7-1/9512
I'm making these changes in stages so that I can get early feedback
and in so doing improve future pull requests.
This changes was tested by generating an new application with esbuild
and deploying it.
attn: @ddh
* switch to double quotes to placate Rubocop
* add some Dockerfile tests
* generate a .node-version file if using_node?
* remove this for now
* reduce the number of layers
also adopt some of the style conventions already in use in the
Dockerfile with respect to quoting and spacing.
* add changelog entry
This was broken in 0019dea and partially fixed for setting config.hosts
to a nil value in 56ecea0.
However, since HostAuthorization coerces the hosts param to an array to
allow a single String or IPAddr as a valid value, the check should do
the same.
Prior to #46858, uses can set `config.hosts = nil` to allow all hosts.
But now it causes `NoMethodError` because the check uses only `empty?`.
Given that the HostAuthorization itself allows taking `nil` as hosts,
I think this breaking change is not intentional. Therefore this commit
fixes the issue by also checking if the value is `nil`.
Previously, HostAuthorization would be added to the middleware stack
whether or not config.hosts had any entries. While HostAuthorization
does check config.hosts before doing computationally expensive things,
its inclusion ends up being easily avoidable overhead on every request.
When running tests that does not initialize rails (e.g. `rake test` under
active_model), it used to just cut off the leading "/" from absolte paths and
report something like
rails test Users/a_matsuda/rails/activemodel/test/cases/api_test.rb:40
that cannot be executed.
Previously, Rails::BacktraceCleaner was both lazily required and
instantiated. While it would end up being loaded during initialization
for apps that use Active Record (due to active_record.backtrace_cleaner
initializer), it would not be loaded until the first request for those
that don't.
The solution is similar to daff36c, however ::Rails is not currently
in the list of eager_load_namespaces. Therefore simply requiring it
seems like the easiest solution.
The removed comment indicating the lazy require is necessary due to load
order dates back to the addition of Rails::BacktraceCleaner in f42c77f.
This predates the integration of Bundler and reorganization of framework
loading, so it is no longer accurate.
* Add CMD and refactor ENTRYPOINT
The CMD will run by default when you run the container without supplying
any arguments but you can choose to overwrite this at runtime by
doing: docker container run -it myapp rails c
The ENTRYPOINT will only create or migrate the database when the default
CMD is invoked. If you choose to run a different command such as the
rails console or a background worker process the db:prepare command
will not run.
* Remove extra space from ENTRYPOINT comment
Follow-up to #46762.
Docker-related files are intended for production deployment, not
development. Therefore, this commit prevents those files from being
generated for plugin dummy apps.
This patch reduces Array object allocations from some Rack middleware per each
request by reusing the Array object that wraps status, headers, and body
objects. This is a Rails version of the same improvements that has already been
pushed to Rack 3.0. https://github.com/rack/rack/pull/1887
When users create a new app or `git clone` an existing app, they may not
realize it is enrolled in decrypted diffing of credentials (or be aware
of the feature).
This commit adds a confirmation message when configuring the Git diff
driver for credentials, to serve as a reminder. The message will be
shown when running `bin/rails credentials:edit` for the first time after
`rails new` or `git clone`.
This commit also silences the enrollment confirmation message when
creating a new app, to reduce noise.
Follow-up to #45543.
In #45543, `CredentialsGenerator#add_credentials_file_silently` was
removed in favor of setting Thor's `quiet: true` option. However, the
call to `CredentialsGenerator` in the app generator was not updated to
use `quiet: true`.
* Add ENV["SECRET_KEY_BASE_DUMMY"]
This is useful when precompiling assets for production as part of a build step that otherwise does not need access to the production secrets.
* Test SECRET_KEY_BASE_DUMMY
When a host is not specified for an `ActionController::Renderer`'s env,
the host and related options will now be derived from the routes'
`default_url_options` and `ActionDispatch::Http::URL.secure_protocol`.
For example, with:
```ruby
Rails.application.default_url_options = { host: "rubyonrails.org" }
Rails.application.config.force_ssl = true
```
Before:
```ruby
ApplicationController.renderer.render inline: "<%= blog_url %>"
# => "http://example.org/blog"
```
After:
```ruby
ApplicationController.renderer.render inline: "<%= blog_url %>"
# => "https://rubyonrails.org/blog"
```
As a consequence, Action Text attachment URLs rendered in a background
job (a la Turbo Streams) will now use `Rails.application.default_url_options`.
Fixes#41795.
Fixeshotwired/turbo-rails#54.
Fixeshotwired/turbo-rails#155.
When calling `rails help` most commands missed their description. We now
show the same descriptions as shown in `rails -T`.
We can show the description after the command name and use some padding
to align the descriptions. Lines are truncated to the width of the
terminal.
Rails::Command had logic for printing help commands not in 'usage':
`print_commands`, `commands` and the `COMMANDS_IN_USAGE` constant. As
these methods were only used by Rails::Command::HelpCommand, they have
been moved HelpCommand.
This also changes the `printing_commands` methods on several classes.
Instead of returning just the commands, they return the commands
with the descriptions. As these are only used for printing help it does
not affect any other code.
Some commands (routes, credentials:diff, etc) show no description yet,
but these can be added later.
As of https://github.com/rails/rails/pull/46525, the behaviour around
before_committed! callbacks has changed: callbacks are run on every
enrolled record in a transaction, even multiple copies of the same record.
This is a significant change that apps should be able to opt into in order
to avoid unexpected issues.
This fixes some issues I found while working on https://github.com/rails/rails/pull/46718
- Some of the tests in `test_runner_test.rb` generate a new test file, then run it. In some cases, the generated tests were failing. The calling test didn't expect this, but didn't fail despite that. So in this PR I have fixed the generated tests to always pass, and added `allow_failure: false` to enforce this.
- Added a missing test for when `PARALLEL_WORKERS=1`.
- Fixed a typo and removed some unnecessary wording in the docs.
Currently if you do this:
```ruby
config.active_record.query_log_tags = [:namespaced_controller]
```
A request that's processed by the `NameSpaced::UsersController` will log as `namespaced_controller='NameSpaced%3A%3AUsersController'`.
By contrast if you set the tag to `:controller` it would log as `controller='user'`, much nicer.
This PR makes the `:namespaced_controller` formatting more similar to `:controller` - it will now log as `namespaced_controller='name_spaced/users'`.