Commit Graph

684 Commits

Author SHA1 Message Date
Jean Boussier
a191321f7b Disable config.add_autoload_paths_to_load_path by default in Rails 7.1
Ref: 668673f779

Now that Zeitwerk is the only autoloader, there no reason
to add autoloaded paths to `$LOAD_PATH`.
2022-01-11 12:05:32 +01:00
Harun Sabljaković
486be06ccb Remove X-Download-Options default header
Since X-Download-Options header is only used by the soon deprecated Internet Explorer, it makes sense to remove this header as a default one.
2022-01-06 10:03:17 +01:00
Rafael Mendonça França
83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rafael Mendonça França
b6bc552c1f
Squashed commit of the following:
commit fdb0b29ad9e25965f506e340ea59b33815927378
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Dec 3 03:39:20 2021 +0000

    Remove deprecated `config` in `dbconsole`

commit 25c4cf82cdb90ad26df96412c25d25e3eda20eb5
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Dec 3 02:35:07 2021 +0000

    Remove deprecated `ActiveRecord::DatabaseConfigurations::DatabaseConfig#spec_name`

commit 887dc810d18b3be04d56975d1a488b5ebac36f3c
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Dec 3 02:27:54 2021 +0000

    Remove deprecated `ActiveRecord::Connection#:in_clause_length`

commit 126319ec3d62b8d0d86bec0c88c3555007f9d4b6
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Dec 3 02:21:49 2021 +0000

    Remove deprecated `ActiveRecord::Connection#allowed_index_name_length`

commit 60e9fd6106027296b4409e9028e0ed6c50091f33
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Nov 19 23:32:42 2021 +0000

    Remove deprecated `ActiveRecord::Base#remove_connection`

commit 7b8546572e3c082140b5958b78d088efe6874af8
Author: Rafael Mendonça França <rafael@rubyonrails.org>
Date:   Fri Nov 19 23:30:17 2021 +0000

    Fix warnings and wrong indentation
2021-12-03 04:02:40 +00:00
Rafael Mendonça França
481343ed91
Merge PR #41769 2021-11-25 19:27:09 +00:00
Rafael Mendonça França
82313145df
Remove deprecated config.active_support.use_sha1_digests 2021-11-19 21:43:22 +00:00
David Heinemeier Hansson
5647a9c1ce
Not needed 2021-11-17 12:23:38 +01:00
Dino Maric
1c19f50110
Upgrade jsbundling-rails version to support the source maps. (#43656) 2021-11-17 12:22:29 +01:00
Martijn Lafeber
a64dd2ae1d When generating form partials, use correct fields for date, time and datetime, timestamp. 2021-10-15 09:03:10 +02:00
Xavier Noria
fe4377098b Restore set_autoload_path triggering before bootstrap
Fixes #43205.
2021-10-04 22:01:23 +02:00
Petrik
b59620c155 Fix railties/CHANGELOG.md for cookie_serializer
The framework defaults file sets the serializer to `:hybrid` instead of
`:marshal`, but we can just remove the actual setting and referer to the
defaults file instead. [ci-skip]
2021-09-16 09:48:09 +02:00
Rafael Mendonça França
d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França
9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
Rafael Mendonça França
fd41ea1f2d
Merge branch 'main' into less-initializers 2021-09-15 17:18:49 -04:00
Christian Sutter
1f4714c3f7 Change default X-XSS-Protection header to '0'
This header has been deprecated and the XSS auditor it triggered
has been removed from all major modern browsers (in favour of
Content Security Policy) that implemented this header to begin with
(Firefox never did).

[OWASP](https://owasp.org/www-project-secure-headers/#x-xss-protection)
suggests setting this header to '0' to disable the default behaviour
on old browsers as it can introduce additional security issues.

Added the new behaviour as a framework default from Rails 7.0.
2021-09-14 14:14:21 +01:00
Xavier Noria
89801b2a43 Depend on ruby/debug, replacing Byebug
ruby/debug is a new debugger that is going to ship with CRuby.

It makes sense for Rails to switch to this one because that is
where the language is heading, and because Byebug is not fully
compatible with Zeitwerk. See

    https://github.com/deivid-rodriguez/byebug/issues/564

While ruby/debug has not been heavily tested with Zeitwerk,
casual usage seems to suggest it works without issues, including
explicit namespaces, which is where Byebug and Zeitwerk conflict.

Byebug is terrific, thanks a lot for all these years. ❤️
2021-09-08 17:35:41 +02:00
Guillermo Iguaran
32612c6d41
Merge branch 'main' into 43114-add-ssl-support-for-postgresql-dbconsole 2021-08-29 13:18:58 -07:00
Guillermo Iguaran
b71a9ccce0 Move most recent CHANGELOG entry to the top of file 2021-08-29 09:59:37 -07:00
Guillermo Iguaran
0d31319562
Merge pull request #43089 from kaukas/template-gem-comments
Support gem comments in Rails templates
2021-08-29 09:57:38 -07:00
Xavier Noria
0c9f6b7f88 Copy edits the railties CHANGELOG 2021-08-29 17:44:25 +02:00
Xavier Noria
3de4aaff5e Update link in README 2021-08-29 17:17:28 +02:00
Linas Juškevičius
18ff32827c
Improve gem comment condition 2021-08-29 13:24:04 +03:00
Michael Bayucot
9f57debbd0 Add SSL support for postgresql in bin/rails dbconsole 2021-08-27 22:22:28 +08:00
Xavier Noria
dc047f71b8 More railties CHANGELOG updates 2021-08-27 09:50:06 +02:00
Xavier Noria
393b8bc8f4 Updates railties CHANGELOG 2021-08-27 09:21:11 +02:00
Petrik de Heus
db947c2917
Add plugin to common command USAGE (#41457)
Because the PluginCommand is defined with `hide_command!`, running
`bin/rails -h` hides the plugin command.

As an alternative to removing the `hide_command!` this adds the plugin
command to the USAGE. Unless it's an engine, because adding an engine to
an engine doesn't make sense.

Both the railtie and engine terms are used so a user can search for both.

[Petrik de Heus + Rafael Mendonça França + Jonathan Hefner]
2021-07-28 17:59:22 -04:00
Petrik
718814a4f2 Improve help for Rake tasks
When running `bin/rails -h` the following messages is shown:

> All commands can be run with -h (or --help) for more information.

This doesn't apply to the commands that are Rake tasks like db:migrate.
If you run `bin/rails db:migrate -h` you'll get the Rake help, which
can be confusing...

Instead, if we replace the `-h` argument with `--describe db:migrate`
Rails outputs the Rake task descriptions, which are a lot more helpful:

    rails db:migrate
        Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog).

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2021-07-21 22:12:08 +02:00
Ryuta Kamizono
e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
Zachary Scott
7373b5819a 💅 complete sentence in railties/CHANGELOG 2021-07-07 08:20:18 +09:00
Loïc Delmaire
056b70ee4f
config_for accepts root shared as an array
Fix a bug introduced by
3fe0ab52df
that raised an undefined method when trying to deep merge an array with
an empty config hash

It also adds a test to clarify config_for behaviour with root arrays: when there's
an env array and a shared array, it should only returns the env key (and not a concatenation)

Closes #42698
2021-07-06 11:57:21 +02:00
Petrik
76f9b7531f Generators should raise an error if an attribute has an invalid index type
When passing an invalid index type to a generator, the index is silently
ignored. For example when misspelling the index:

    bin/rails g model post title:string:indxe

Instead of silently ignoring the invalid index, the generator should
raise an error.

This continues the work in d163fcd6208c9b0507746888c7fb4a6f934303ce
where we started raising errors if the attribute types are invalid.
2021-07-04 19:13:24 +02:00
Alex Ghiculescu
de238125ef Generate less initializers in new/upgraded Rails apps
Currently when you make a new Rails app, we generate a lot of initializers. For new users, I think we should try and include as few as possible - the less files, the less daunting a new app is. And for upgrades I'd like to [continue to simplify the update process](https://github.com/rails/rails/pull/41083), in this case by not bringing back initializers you have probably already dismissed or modified.

In this PR I'm proposing we remove two initializers: `application_controller_renderer.rb` and `cookies_serializer.rb`:

**`application_controller_renderer.rb`**. This configures [`ActionController::Renderer`](https://api.rubyonrails.org/classes/ActionController/Renderer.html), for rendering views outside of controller actions. I don't think this is something most Rails apps will need (certainly not on day 1); users can configure this feature when they need it.

**`cookies_serializer.rb`**. This was added for [Rails 4.1](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#cookies-serializer). The behaviour is:

- For new apps, the initializer says `:json`.
- For upgraded apps that don't have the initializer, it is added with value `:marshal`.
- If there's no initializer, the [default value](c9a89a4067/actionpack/lib/action_dispatch/middleware/cookies.rb (L589)) is `:marshal`.

Since nobody should be upgrading direct from Rails 4.0 to Rails 7.0, we can simplify this by using new framework defaults. So the behavior will now be:

- For new apps, `config.load_defaults("7.0")` sets the value to `:json`.
- The `new_framework_defaults_7_0.rb` file explains this, and suggests using `:hybrid` to be upgrade to JSON cookies.
- No changes to [the code](c9a89a4067/actionpack/lib/action_dispatch/middleware/cookies.rb (L589)); the default value is `:marshal` if you don't set one.

So if you were not setting a `cookies_serializer` previously and you want to keep using `:marshal`, you'll need to explicitly set this before using `config.load_defaults("7.0")`, otherwise it will switch to `:json`. The upside of this is you won't get the `cookies_serializer.rb` file created for you every time you upgrade.
2021-06-18 16:13:05 -05:00
Zachary Scott
96d50dcf9a Use the current Rails->npm_version for package.json
Fixes https://github.com/rails/rails/issues/42012

This takes the npm_version method from rails/release.rb and just copies it
f95c0b7e96/tasks/release.rb (L26-L36)

Co-authored-by: Alex Ghiculescu <alexghiculescu@gmail.com>
2021-06-09 10:17:46 -05:00
Rafael Mendonça França
babc9eae9d
Merge pull request #40745 2021-06-08 23:32:28 +00:00
Petrik
d163fcd620 Generators should raise an error if a field has an invalid type
Generators can create invalid migrations when passing an invalid
field type. For example, when mixing up the name and type:

    bin/rails g model post string:title

This will generate a field for post with a column named `string`
of the type `title`, instead of a column named `title` of the type
`string`. Running the migration will result in an error as the type
`title` is not known to the database.

Instead of generating invalid files, the generator should raise an error
if the type is invalid. We validate the type by checking if it's a
default migration types like: string, integer, datetime, but also
references, and rich_text.

If the type isn't a default type, we can ask the
database connection if the type is valid. This uses the `valid_type?`
method defined on each database adapter, which returns true if the
adapter supports the column type. This method is also used by the
SchemaDumper.

Some gems like 'postgis' add custom types. The 'postgis' gem adds these
types by overriding the `native_database_types` method.
That method is used by `valid_type?` method on the database adapter,
making this change compatible with 'postgis'.
2021-05-29 15:17:36 +02:00
Xavier Noria
d5a89c2841 Wording tweak in CHANGELOG [skip ci]
Say "also" so that it is clear that we are not defining what tmp:clear
does for people not familiar with the task.
2021-05-29 11:58:52 +02:00
George Claghorn
00feff918e rails tmp:clear: clear tmp/storage 2021-05-28 22:34:49 -04:00
Jean Boussier
1e56b1d115 Fix ruby-master test suite (Psych 4.0.0)
Ruby master ships with Psych 4.0.0 which makes `YAML.load`
defaults to safe mode (https://github.com/ruby/psych/pull/487).

However since these YAML files are trustworthy sources
we can parse them with `unsafe_load`.
2021-05-19 14:21:21 +02:00
Gannon McGibbon
cc557db0e2 Allow loading nested locales in engines 2021-04-21 17:45:09 -04:00
Jean Boussier
3fe0ab52df Ensure Rails.application.config_for always cast hashes to ActiveSupport::OrderedOptions.
Fix: #42037
2021-04-21 17:32:42 +02:00
Hartley McGuire
7bfcf4b313 Remove Rack::Runtime and deprecate referencing it
Previous discussion: #38412, #38325, 37423e4, 24f9c03

- Rack::Runtime is replaced by FakeRuntime, which is a dummy middleware
  that just passes requests on and cannot be used in middleware operations
- Using Rack::Runtime in middleware operations (relative inserts, moves,
  etc.) throws a deprecation warning and uses FakeRuntime instead
- if an application adds Rack::Runtime explicitly (use, unshift, etc.),
  then the deprecation warning does not happen and FakeRuntime is
  ignored
- docs are updated to no longer reference Rack::Runtime
2021-04-12 14:31:12 -04:00
Debbie Milburn
03aa08526a
Merge branch 'main' into add-rails-development-hosts-env-variable 2021-03-09 11:59:11 -05:00
Gannon McGibbon
bf57e7ff9d Add app concern and test keepfiles to generated engine plugins 2021-03-09 00:04:29 -05:00
Debbie Milburn
8c50571808 Add RAILS_DEVELOPMENT_HOSTS to allow adding authorized hosts for development
Co-authored-by: Josh Abernathy <joshaber@gmail.com>

Update railties/CHANGELOG.md

Co-authored-by: Gannon McGibbon <gannon@hey.com>

Update railties/lib/rails/application/configuration.rb

Co-authored-by: Gannon McGibbon <gannon@hey.com>

Use yield block to safely alter env variables

Remove trailing whitespace

Update railties/CHANGELOG.md wording

Co-authored-by: Marivaldo Cavalheiro <marivaldo@gmail.com>

Have comma separated list ignore spaces

Add missing comma
2021-03-05 14:03:37 -05:00
Gannon McGibbon
9790ae9567 Stop generating a license for in-app plugins 2021-03-01 13:38:39 -05:00
Alex Ghiculescu
1d1c9f9fe7 Avoid footguns in rails app:update
While upgrading a Rails 6 app to Rails 6.1, I noticed that `rails app:update` asks you to review some file changes that you'd basically never want to accept. In this PR, I propose we make the update task do a bit less, by not offering to overwrite files where the developer has almost certainly changed them from the default. Specific changes:

Don't replace the following files, as they change very rarely at the framework level, so if the user has changes they almost certainly intend to keep them:
- [config/boot.rb](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/boot.rb.tt)
- [config/environment.rb](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/environment.rb.tt)
- [config/storage.yml](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt)
- [config/spring.rb](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/spring.rb.tt)
- [config/cable.yml](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt)
- [config/puma.rb](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt)
- [config.ru](https://github.com/rails/rails/commits/master/railties/lib/rails/generators/rails/app/templates/config.ru.tt)

Don't overwrite the config/locales directory. There's basically no chance you'll want to replace your current `config/locales/en.yml` with a [hello world](https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/locales/en.yml).

Don't replace config/routes.rb. It's so unlikely that the user will want to replace their routes file with [an empty file](https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/routes.rb.tt).

With these changes, you will still be prompted to accept/decline changes to these files when doing an update:

- config/application.rb
- config/environments/{development|test|production}.rb
- All the default [initializers](https://github.com/rails/rails/tree/master/railties/lib/rails/generators/rails/app/templates/config/initializers) that you already have a copy of. I go back and forth on also opting some of these out, specifically `assets.rb`, `filter_parameter_logging.rb`, and `inflections.rb` which seem pretty likely to have been changed.
- All the default [binstubs](https://github.com/rails/rails/tree/master/railties/lib/rails/generators/rails/app/templates/bin) that you already have a copy of. I decided to still make the user review these, as bugs here are going to be annoying to debug, but it is good to use the latest versions if possible.
2021-02-09 12:20:56 -07:00
Ryuta Kamizono
978308ac87 Fix markup in CHANGELOGs [ci skip] 2021-02-07 05:45:53 +09:00
Prateek Choudhary
eb261937ac Change default branch for new Rails projects and plugins to main
This commit changes the default branch of new Rails projects
and plugins from master to main.
2021-01-16 08:49:03 +05:30
Michael Duchemin
9fee1f36dc
Fix system test scaffold generator for vowels
Fix issue where running "rails g scaffold Author" will create system
test names like "creating a Author" and "updating a Author" so that
there are not grammatical errors. Now running "rails g scaffold Author"
will generate "should create Author", "should update Author", and
"should destroy Author" which works around the article vowel-sound
agreement issues.

Fixes #40744
2020-12-09 19:43:25 -05:00
Simon Perepelitsa
1911673e67 Add benchmark method that can be called from anywhere 2020-12-04 15:52:10 +03:00