Commit Graph

15463 Commits

Author SHA1 Message Date
Mike Dalessio
f9e86f1bf5
Improve how the sessions generator adds bcrypt (#52346)
* doc: fix CHANGELOG message for sessions generator

* fix: Sessions generator adds bcrypt more robustly

Use Thor's `uncomment_lines` instead of `gsub_file`.

If the Gemfile does not contain bcrypt, either commented or
uncommented, then run `bundle add bcrypt`.

Make sure all bundler commands run within `Bundler.with_original_env`
to avoid bundler resolution problems while trying to resolve bundler
dependencies. Typically the failure mode here is seeing:

> Could not find bcrypt-3.1.20 in cached gems or installed locally (Bundler::GemNotFound)

while bootstrapping the process that will run bundle-install or bundle-add.
2024-07-17 08:14:31 +02:00
David Heinemeier Hansson
7b1ceb7659
Add basic sessions generator (#52328)
* Add basic sessions generator

* Excess CR

* Use required fields

* Add sessions generator test

* Fix generated migration

* Test migration content

* Appease rubocop

* Add CHANGELOG
2024-07-16 18:05:53 +02:00
David Heinemeier Hansson
3ce3a4e94c
Remove channels from default app/ structure (#52344)
* Remove channels from default app/ structure

Now that Hotwire is the default, the majority of apps won't need custom
channels. And those that do can get the files back via the generator.

* Remove trailing space

* Remove additional needless elements

* No longer to be generated

* No longer generated
2024-07-16 16:55:00 +02:00
David Heinemeier Hansson
f973075aa4
Drop default permissions policy initializer (#52341)
It is too rarely used to warrant such a prominent placement in the
default structure.
2024-07-16 14:41:16 +02:00
David Heinemeier Hansson
2f92b1c94e
Add not-null modifier to migrations (#52327)
* Add migration type modifier for not-null attributes

* Explain change

* Appease rubocop by using AS helper

* Deal with nil
2024-07-16 14:37:42 +02:00
Jerome Dalbert
c01a846658
Add script folder and generator (#52335)
Add a new script default folder to hold one-off or general purpose
scripts, such as data migration scripts, cleanup scripts, etc. Also add
a script generator to create such scripts.

Co-authored-by: Haroon Ahmed <haroon.ahmed25@gmail.com>
2024-07-16 12:28:20 +02:00
David Heinemeier Hansson
44548856c4 Not worth the active support require line 2024-07-16 12:15:06 +02:00
David Heinemeier Hansson
009f767ca7 No longer used 2024-07-16 12:11:55 +02:00
Gannon McGibbon
e3cc8fe707 Only enable routing source locations when using routes command
The overhead isn't necessary for development when not using the routes
command. We can omit it entirely by checking for existence of the routes
command constant.
2024-07-11 18:53:20 -05:00
heka1024
fc7637103a Prefer ETag over Last-Modified for fresh_when and stale? according to the HTTP specification 2024-07-05 10:18:43 +02:00
Juan Vásquez
3d737cd8ef
Update CHANGELOG.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2024-06-28 10:14:10 -06:00
Juan Vasquez
2f580264d5 Add bin/rake stats deprecation changelog
Related #47713
2024-06-28 07:55:44 -06:00
Rafael Mendonça França
292c127d46
Merge pull request #47713 from JuanVqz/railties/thor-stats-task
Use Thor for built-in stats task
2024-06-26 17:06:35 -04:00
Rafael Mendonça França
fca2a5e8a6
Merge pull request #51733 from seanpdoyle/document-yield-head
Mention `yield :head` in Guides
2024-06-26 17:03:40 -04:00
Rafael Mendonça França
004ab15650
Merge pull request #52215 from p8/railties/document-action-mailer-perform-caching
Document `action_mailer.perform_caching` in environment files. [ci-skip]
2024-06-26 17:01:38 -04:00
Rafael Mendonça França
8a452230c5
Merge pull request #52224 from Earlopain/rake-rdoc-abort
Fix `rake rdoc` when the timestamp file is empty
2024-06-26 16:57:55 -04:00
Rafael Mendonça França
5103ba86e4
Merge pull request #52222 from Earlopain/skip-sprockets-newline
Fix an extra newline in `development.rb` when sprocket gets skipped
2024-06-26 16:18:22 -04:00
Rafael Mendonça França
716e4a7d32
Merge pull request #52091 from jasonkim/to-time-use-timezone
Add a config for preserving timezone information when calling `to_time` on TimeWithZone object
2024-06-26 16:16:05 -04:00
Earlopain
540103c6eb
Fix rake rdoc when the timestamp file is empty
This happens when rdoc fails during generation as the timestamp
is only written on successful attemps. The file is created anyways though
2024-06-26 17:07:25 +02:00
Earlopain
d8534d40e4
Fix an extra newline in development.rb when sprocket gets skipped 2024-06-26 12:43:17 +02:00
Petrik
a787333b04 Document action_mailer.perform_caching in environment files.
This setting is set to false in all enviroments, but it's a bit unclear
why this needs to be set.
2024-06-25 15:46:10 +02:00
Juan Vasquez
df64ba0a06 Use Thor for built-in stats task
Currently, we use both Thor and Rake for `bin/rails` commands.
We eventually want to get all the built-ins task promoted to Thor Commands.
This migrates the `stats` task to Thor.
2024-06-24 09:12:21 -06:00
Sam Ruby
0350187882 Fix mailer templates to be rubocop compliant
- spaces around array elements
- only emit blank lines between new blocks of code
2024-06-23 07:28:25 -04:00
Rafael Mendonça França
fc60a394c0
Merge pull request #52175 from y-yagi/correctly_generate_devcontainer_for_mysql2
Correctly generate Devcontainer setting for applications that using mysql2 gem
2024-06-21 17:09:17 -04:00
Rafael Mendonça França
bc67961679
Merge pull request #52179 from Uaitt/Dockerfile-FromAsCasing-offenses
Fix `FromAsCasing` offense while building a Dockerfile
2024-06-21 16:59:59 -04:00
Jeremy Daer
eea3d5adcf Revert lazy routesets (#52012) due to polymorphic routing regression
References https://github.com/rails/rails/pull/52012#issuecomment-2183415161

Revert "Merge pull request #52033 from Shopify/amend_lazy_routes_changelog"

This reverts commit 743128b2307b6e1bd59acb9dc8358592d264c573, reversing
changes made to 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8.

Revert "Merge pull request #52012 from Shopify/defer_route_drawing"

This reverts commit 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8, reversing
changes made to 5dabff4b7bf4cc5e2e552efb78c6a3f3e44bed37.
2024-06-21 13:59:43 -07:00
Lorenzo Zabot
9b43e91108 Fix FromAsCasing offenses while building a Dockerfile 2024-06-21 14:07:02 +02:00
Yuji Yaginuma
fd0d2de9ad Correctly generate Devcontainer setting for applications that using mysql2 gem
Currently, `devcontainer` command sets an adapter name, but
`DevcontainerGenerator` requires a database name.
16d8b82d5e/railties/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb (L11)
16d8b82d5e/railties/lib/rails/generators/database.rb (L6)

So the `devcontainer` command doesn't generate the setting for
MySQL. This fixes to generate the correct setting.
2024-06-21 17:16:40 +09:00
Sam Ruby
8eafbc1b19 make "g scaffold" with no field produce rubocop compliant code
When there are no fields:
  * Omit blank line in migration prior to "t.timestamps"
  * Omit leading and trailing spaced in empty hashes in
    create and update controller and api functional tests

Co-authored-by: zzak <zzakscott@gmail.com>
2024-06-20 22:11:09 -04:00
Sean Doyle
5fa61101c9 Mention yield :head in Guides
Follow up to [#50527][]

Highlight the presence of the `yield :head` pattern established by
`turbo-rails` and adopted by Rails as part of [#50527][].

New applications will generate their application layout with `yield
:head`, so mention that in the documentation.

Also include the `yield :head` call in generated plugin layouts.

[#50527]: https://github.com/rails/rails/pull/50527
2024-06-14 11:16:39 +02:00
Jason Kim
9dcf17ec4c Add a config for preserving timezone information
when calling `to_time` on TimeWithZone object

Co-authored-by: jhawthorn <jhawthorn@github.com>
2024-06-13 14:56:40 -07:00
Rafael Mendonça França
5cb2603d56
Merge pull request #52040 from zzak/re-52026
Rails::ConsoleMethods deprecation warning should point to the source
2024-06-13 15:25:35 -04:00
Rafael Mendonça França
638f645097
Merge pull request #52115 from deepakmahakale/notes-ui-changelog
Add changelog for the new internal route rails/info/notes [ci skip]
2024-06-13 13:22:29 -04:00
Deepak Mahakale
306d99f8ca
Add changelog for the new internal route rails/info/notes 2024-06-13 17:14:37 +00:00
Yuji Yaginuma
44a64ce904 Correctly output driven_by setting for Development Containers
Currently, `ENV["SELENIUM_HOST"]` is evaluated when generating a file. So
the result was the following.

```
  driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
    browser: :remote,
    url: "http://:4444"
  }
```

This PR fixes to output the URL setting just as a string. The after
result is the following.

```
  driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
    browser: :remote,
    url: "http://#{ENV["SELENIUM_HOST"]}:4444"
  }
```
2024-06-13 16:30:20 +09:00
Rafael Mendonça França
68b6a1cc57
Merge pull request #52064 from feliperaul/improve_message_verifier_and_signed_id_docs
[ci skip] Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
2024-06-12 18:00:28 -04:00
Felipe
ad20d9e7ec
Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
The documentation on ActiveSupport::MessageVerifier used the “sensitive data” string as an example; that wording might induce the developer to think we’re dealing with encryption, while the payload is actually only Base64 encoded and is not protected at all.

We also improve the documentation on ActiveRecord::SignedId, which uses MessageVerifier and thereby will also expose the ID as encoded cleartext, making explicit that it’s not encryption, only signing.

Lastly, we refer the developer to MessageEncryptor if the payload needs to be encrypted.
2024-06-12 20:46:27 +00:00
Rafael Mendonça França
df32c3837d
Merge pull request #52100 from jdlubrano/fix-activerecord-configs-shadowing
Fix ActiveRecord configs variable shadowing
2024-06-12 15:44:34 -04:00
Rafael Mendonça França
c666dac546
Merge pull request #49240 from deepakmahakale/notes-ui
Add an internal route for bin/rails notes
2024-06-12 15:08:49 -04:00
Rafael Mendonça França
db1bbc4070
Merge pull request #52069 from otorain/fix-redundant-package-in-ci-template
remove redundant database package from ci.yml.tt template
2024-06-12 15:06:33 -04:00
Joel Lubrano
e6d924ea17
Add configuration test for ActiveRecord being loaded prior to new framework defaults 2024-06-12 18:59:40 +00:00
Rafael Mendonça França
8229339593
Merge pull request #52095 from ioquatix/rack-version-constant
Print `Rack.release` as part of default Rails welcome page.
2024-06-12 14:24:24 -04:00
Samuel Williams
423959b5b5
Print Rack.release as part of default Rails welcome page. 2024-06-12 10:36:25 +09:00
Rafael Mendonça França
2ebb508cd8
Merge pull request #52086 from y-yagi/bring_back_pumarb_to_app_update
Bring back `puma.rb` to target of `app:update`
2024-06-11 19:37:18 -04:00
Yuji Yaginuma
e4f8604602 Bring back puma.rb to target of app:update
This is a partial revert of #41083.

`puma.rb` may update by users, but  Rails has improved `puma.rb` sometimes.
For example, 06d614ada9e4609ff83659e842f48af3232a03a5 and f719787c582839fd2fcd886d70b43da3ddad2ceb.

To allow users to know those improvements, I think we should update
`puma.rb` by `app:update`.
2024-06-11 16:06:30 +09:00
Hartley McGuire
c2901eb084
Restore some config.secret_key_base functionality
The [deprecated secrets removal][1] ended up removing a bit of
non-deprecated functionality related to config.secret_key_base:

- the original implementation prioritized the value of
  config.secret_key_base over other sources in all environments
- if unset, the value of config.secret_key_base would be updated to
  whichever fallback value was found

The new implementation only sets config.secret_key_base to a fallback
value when Rails.env.local?, and never considers it at all in
production.

This commit aims to restore this missing functionality as well as
simplify the implementation:

- Rails.application.secret_key_base now always delegates to
  config.secret_key_base (like the pre-secret-removal implementation)
- secret_key_base validation was moved from the reader to the writer
- config.secret_key_base now handles setting itself to a fallback value
  when unset
- In addition, generate_local_secret was simplified because it
  previously did 3 things: file manipulation, setting
  config.secret_key_base, and returning a value. Now it only creates the
  file if necessary and returns the value stored in it

The new implementation has an additional benefit, which is that manually
set config.secret_key_base values are now validated, whereas previously
only fallback values were validated.

[1]: 0c76f17f2dbf0d7ad90c890e6f334743cacce41f

Co-authored-by: Petrik <petrik@deheus.net>
2024-06-10 23:04:23 -04:00
ian
5871d21d5d remove the redundant database package from ci.yml.tt template 2024-06-10 23:52:28 +08:00
zzak
33a748a7cf
Rails::ConsoleMethods deprecation warning should point to the source
Before:

```
 (called from Rails::ConsoleMethods.include at /home/zzak/code/rails/railties/lib/rails/console/methods.rb:6)
```

After:

```
 (called from block in <class:Engine> at /home/zzak/.rbenv/versions/3.4.0/lib/ruby/gems/3.4.0+0/bundler/gems/mission_control-jobs-7295d75ed735/lib/mission_control/jobs/engine.rb:73)
```

Co-authored-by: Wojciech Wnętrzak <w.wnetrzak@gmail.com>
2024-06-08 19:54:56 +09:00
Eileen M. Uchitelle
03187f6b1f
Merge pull request #51916 from fatkodima/migrations-primary-without-db-tasks
Fix running migrations on other databases when `database_tasks: false` on primary
2024-06-08 00:58:43 -07:00
fatkodima
c5ac244c0d Fix running migrations on other databases when database_tasks: false on primary 2024-06-06 21:00:54 +03:00