Commit Graph

7274 Commits

Author SHA1 Message Date
stephannv 073e522578 Fix web-console version for Rails 6.1 2020-11-05 10:06:27 -03:00
Jonathan Hefner acc837e91a Move Spring machinery back to bin files
Follow-up to #39746.

This shifts the responsibility of loading Spring from `config/boot.rb`
back to the relevant bin files.

Fixes #40518.
Closes #40521.
2020-11-03 16:35:40 -06:00
Rafael Mendonça França 8389f9902c
Preparing for 6.1.0.rc1 release 2020-11-02 21:12:47 +00:00
Rafael França 890035fd4a
Merge pull request #40365 from ankurp/fix/standardize-js-package-name
Follow npm/JS standard for package name
2020-11-02 15:29:41 -05:00
Eugene Kenny 67e69e8db4
Merge pull request #38829 from cbisnett/host_authorization_exclude
Add request exclusion to Host Authorization
2020-11-02 20:22:35 +00:00
Rafael França 5f40eca4a5
Merge pull request #39832 from p8/scaffold-generator-inflection-check
Raise if camelcase inflection impossible in generator
2020-11-02 15:18:26 -05:00
Chris Bisnett 1f767407cb Add request exclusion to Host Authorization
In the same way that requests may need to be excluded from forced SSL,
requests may also need to be excluded from the Host Authorization
checks. By providing this additional flexibility more applications
will be able to enable Host Authorization while excluding requests
that may not conform. For example, AWS Classic Load Balancers don't
provide a Host header and cannot be configured to send one. This means
that Host Authorization must be disabled to use the health check
provided by the load balancer. This change will allow an application
to exclude the health check requests from the Host Authorization
requirements.

I've modified the `ActionDispatch::HostAuthorization` middleware to
accept arguments in a similar way to `ActionDispatch::SSL`. The hosts
configuration setting still exists separately as does the
hosts_response_app but I've tried to group the Host Authorization
settings like the ssl_options. It may make sense to deprecate the
global hosts_response_app if it's only used as part of the Host
Authorization failure response. I've also updated the existing tests
as the method signature changed and added new tests to verify the
exclusion functionality.
2020-11-02 20:16:29 +00:00
Eugene Kenny 56c9be11ad Tidy up comments in environment configuration files [ci skip]
https://guides.rubyonrails.org/api_documentation_guidelines.html#wording
2020-11-02 19:51:58 +00:00
Eugene Kenny b7eaaf73fb Update comment about reloading in development.rb [ci skip]
This comment predates the existence of `reload_classes_only_on_change`.
2020-11-02 19:36:26 +00:00
Edouard Chin 868866c1fd
Allow a new `server` Railtie block:
- This is similar to other railties blocks (such as `console`,
  `tasks` ...). The goal of this block is to allow the application
  or a railtie to load code after the server start.

  The use case can be to fire the webpack or react server in
  development or start some job worker like sidekiq or resque.

  Right now, all these tasks needs to be done in a separate
  shell and gem maintainer needs to add documentation on
  how to run their libraries if another program needs to run
  next to the Rails server.

  This feature can be used like this:

  ```ruby
    class SuperRailtie < Rails::Railtie
      server do
        WebpackServer.run
      end
    end
  ```
2020-11-02 18:11:41 +00:00
Rafael França d52ece70f0
Merge pull request #40492 from nateberkopec/puma5
Upgrade Puma to 5.x
2020-11-02 12:48:32 -05:00
Jonathan Hefner b38c2c1a84 Tweak generated default filter_parameters
Follow-up to #34218.

This removes some filters that could filter innocuous fields such as
`author_name`.  Filtering such fields might be surprising, especially to
people generating their first Rails app.

This commit also changes the `:password` filter to `:passw` so that it
can also filter fields such as `passwd`.
2020-11-02 10:12:32 -06:00
Nate Berkopec b8af0fd2d7
Upgrade Puma to 5.x 2020-11-01 14:50:27 -07:00
Rafael Mendonça França 80f7fd52b2
Remove frozen_string_literal from generated file 2020-10-30 00:45:22 +00:00
Rafael França e68d39f455
Merge pull request #39746 from jonathanhefner/springy-boot
Check environment before loading Spring in boot.rb
2020-10-29 20:44:45 -04:00
Arlston Fernandes 2711dcc9a6
Customise the header name for `ActionDispatch::RequestId`
by setting `config.action_dispatch.request_id_header` to the desired value

* Ensure HTTP_X_REQUEST_ID presence to maintain compatiblility

* Use req.headers[] to fetch header rather than ENV methods

* Update configuration doc to match existing descriptions

* Add changelog entry for action_dispatch.request_id_header
2020-10-30 00:31:09 +00:00
Rafael Mendonça França 576fb33ba3
Remove unneeded requires 2020-10-30 00:26:11 +00:00
Rafael Mendonça França 3c18a0cca8
Remove deprecated required option on the model generators 2020-10-30 00:26:10 +00:00
Rafael Mendonça França 8992a7d0c2
Remove deprecated `rake initializers` tasks 2020-10-30 00:26:09 +00:00
Rafael Mendonça França e152f83c64
Remove deprecated `rake routes` tasks 2020-10-30 00:26:08 +00:00
Rafael Mendonça França 01f0020a55
Remove deprecated `rake dev:cache` tasks 2020-10-30 00:26:08 +00:00
Rafael Mendonça França c0728ad321
Remove deprecated support for using the `HOST` environment variable to specify the server IP 2020-10-30 00:26:07 +00:00
Rafael Mendonça França 5a7028a1a5
Remove deprecated `server` argument from the rails server command 2020-10-30 00:26:06 +00:00
Rafael Mendonça França 6204651412
Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` ENV 2020-10-30 00:26:06 +00:00
Rafael Mendonça França 8513769ad6
Remove deprecated `connection` option in the `rails dbconsole` command 2020-10-30 00:26:05 +00:00
Rafael Mendonça França 227d04f46a
Remove depreated `rake notes` tasks 2020-10-30 00:26:04 +00:00
Rafael Mendonça França 64efe502f3
Change `ActionDispatch::Response#content_type` to return the full Content-Type header
And deprecate the config to keep the previous behavior.
2020-10-30 00:25:49 +00:00
Rafael Mendonça França fd24cf1c5d
Return `false` when enqueuing a job is aborted 2020-10-30 00:25:31 +00:00
eileencodes 31461d8a79
Implement granular role and shard swapping
This change allows for a connection to be swapped on role or shard for a
class. Previously calling `connected_to` would swap all the connections
to a particular role or shard. Granular connection swapping is useful
for swapping one connection to reading while leaving all other
connection classes on writing.

The public methods on connection handler have been updated to behave the
same as they did previously on the different handlers. The difference
however is instead of calling
`ActiveRecord::Base.connection_handlers[:reading].clear_all_connections!`
you now call
`ActiveRecord::Base.connection_handler.clear_all_connections!` which
will clear based on current role set by a `connected_to` block. Outside
the context of a `connected_to` block, `clear_all_connections!` can take
an optional parameter to clear specific connections by role.

The major changes in this PR are:

* We introduced a `legacy_connection_handling` configuration option that
is set to true by default. It will be set to `false` for all new
applications.
* In the new connection handling there will be one only connection
handler. Previously there was a connection handler for each role. Now
the role is stored in the `PoolManager`. In order to maintain backwards
compatibility we introduced a `LegacyPoolManager` to avoid duplicate
conditionals. See diagram in PR body for changes to connection
management.
* `connected_to` will now use a stacked concurrent map to keep track of
the connection for each class. For each opened block the `class`,
`role`, and `shard` will be added to the stack, when the block is exited
the `class`, `role`, `shard` array will be removed from the stack.
* With these changes `ActiveRecord::Base.connected_to` will remain
global. If called all connections in the block will use the `role` and
`shard` that was switched to. If called with a parent class like
`AnimalsRecord.connected_to` only models under `AnimalsRecord` will be
switched and everything else will remain the same.

Examples:

Given an application we have a `User` model that inherits from
`ApplicationRecord` and a `Dog` model that inherits from
`AnimalsRecord`. `AnimalsRecord` and `ApplicationRecord` have writing
and reading connections as well as shard `default`, `one`, and `two`.

```ruby
ActiveRecord::Base.connected_to(role: :reading) do
  User.first # reads from default replica
  Dog.first # reads from default replica

  AnimalsRecord.connected_to(role: :writing, shard: :one) do
    User.first # reads from default replica
    Dog.first # reads from shard one primary
  end

  User.first # reads from default replica
  Dog.first # reads from default replica

  ApplicationRecord.connected_to(role: :writing, shard: :two) do
    User.first # reads from shard two primary
    Dog.first # reads from default replica
  end
end
```

Things this PR does not solve:

* Currently there is no API for swapping more than one but not all
connections. Apps with many primaries may want to swap 3 but not all 10
connections. We plan to build an API for that in a followup PR.
* The middleware remains the same and is using the global switching
methods. Therefore at this time to use this new feature applications
must manually switch connections. We will also address this in a
followup PR.
* The `schema_cache` is currently on the `PoolConfig`. We plan on trying
to move this up to the `PoolManager` or elsewhere later on so each
`PoolConfig` doesn't need to hold a reference to the `schema_cache`.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-10-28 15:11:35 -04:00
Eugene Kenny 9d1f3b7d52 Fix a typo in new_framework_defaults_6_1.rb 2020-10-27 23:44:58 +00:00
Marc Schütz f955cb8a66 Clarify that some configuration still needs to happen in config/application.rb [ci skip] 2020-10-27 16:48:06 +01:00
Ryuta Kamizono 154ee7b4b0 Revert "Don't enable Zeitwerk on MRI in 6.1 load_defaults"
This reverts commit 379db92364.

Reason: 94ba417ece (r41923157)
2020-10-25 15:51:36 +09:00
Eugene Kenny 379db92364 Don't enable Zeitwerk on MRI in 6.1 load_defaults
It's already handled by loading the 6.0 defaults two lines up.
2020-10-24 02:14:58 +01:00
Loren Norman 1f9a5dd36b fix broken handling of unknown http methods 2020-10-23 23:34:58 +01:00
Jonathan Hefner 72d10e218b Check environment before loading Spring in boot.rb
In #39632, `boot.rb` was changed to load `bin/spring`, with the
intention of adding a check to Spring itself that would prevent Spring
from running in production environments.  However, in a production
environment, the Spring gem may not be installed.  Furthermore,
`bin/spring` may raise an error other than `LoadError` if it has been
overwritten by e.g. `bundle binstubs` as part of the deployment process.
Therefore, this commit adds the environment check to `boot.rb`.

This commit also changes the app generator to generate `bin/spring`
directly, instead of delegating to `bundle exec spring binstub`.  This
addresses an issue with the `--skip-bundle` flag.  Previously,
`--skip-bundle` caused `bin/spring` to not be generated. Thus the user
had to manually run `bundle exec spring binstub` later, though that was
not documented nor explained.  Now, `bin/spring` is always generated.
Additionally, by guaranteeing that `bin/stub` is generated, we avoid the
need for `rescue LoadError` in `boot.rb`.
2020-10-22 12:25:06 -05:00
Nick Wolf 7cc2b57b8d
Refactor railsrc file location to be xdg compliant (#39411)
* Refactor railsrc file location to be xdg compliant

The XDG Base Directory Specification (which is currently used by
FOSS projects such as Git, Tmux, Pry, Rspec) provides a default
location for various file formats, including config/rc files.

This comment refactors app_generator.rb to load railsrc from
XDG_CONFIG_HOME if both XDG_CONFIG_HOME is set and rails/railrc
exists within the XDG_CONFIG_HOME location.

To maintain backwards compatibility it defaults back to ~/.railsrc
if either XDG_CONFIG_HOME is not set or there is no rails/railsrc.

* Refactor default_rc_file based on jonathanhefner PR feedback

* Update generators/rails/app/USAGE to explain railsrc XDG compliance

* Refactor default_rc_file based on sinsoku PR feedback

* Add test for ARGVScrubber.default_rc_file method

fileutils is required because tmpdir does not allow you to create a new
temp directory with a set title 'inside' another temporary directory, a
file is created for railsrc because tempfile creates a custom and unique
name preventing the specification of a file called 'railsrc'

Currently this test is failing because the ARGVScrubber class seems to
be loading directly from the gem (which still has the previous code)
rather than from the file itself. (loading the code in a pry session
and using show-method ARGVScrubber.default_rc_file reveals it is coming
from
gems/railties-6.0.3.3/lib/rails/generators/rails/app/app_generator.rb:536
instead of
railties/lib/rails/generators/rails/app/app_generator.rb

* Switch to double quote strings

* Add file deletion for argv_scrubber test

* Refactor test_xdg_config_no_custom_rc with jonathanhefner feedback

* Add Changelog for railsrc xdg-specification compliance

* Apply backtick and whitespace refactoring suggestsions from jonathanhefner

* Apply jonathanhefner suggested Changelog refactoring

[Rafael Mendonça França + Nick Wolf + Jonathan Hefner]
2020-10-21 01:21:07 -04:00
Ankur Patel e22bcc2409 Follow npm/JS standard for package name
Currently when a new rails app is created it uses the app name as it and puts
it in the package.json name. According to npm and JS standards package names
do not have capital letters and should not be using the PascalCase that is
used in Rails app name. This change is to convert app name to using snake case
but with dashes
2020-10-11 07:42:01 -04:00
Jonathan Hefner 33fdae0584 Fix backtraces for generated plugin tests
`Minitest.plugin_rails_init` sets `Minitest.backtrace_filter` to
`Rails.backtrace_cleaner` right before tests are run, overwriting the
value set in test_helper.rb.

`Rails.backtrace_cleaner` silences backtrace lines that do not start
with `Rails.root` followed by e.g. "lib/" or "test/".  Thus when
`Rails.root` is a subdirectory of the project directory -- for example,
when testing a plugin that has a dummy app -- all lines of the backtrace
are silenced.

This commit adds a fallback such that when all backtrace lines are
silenced, the original `Minitest.backtrace_filter` is used instead.

Additionally, this commit refactors and expands existing test coverage.
2020-10-07 15:40:56 -05:00
Akira Matsuda c01aace309 If it respond_to a method, the method should be public_sendable 2020-10-07 11:25:26 +09:00
Akira Matsuda 0bfa02aba3 This kind of wrapper should better not be able to call private methods 2020-10-07 11:12:02 +09:00
Akira Matsuda a412e4da64 Get rid of unnecessary meta programming
Each stacked operation is a Proc object instead of operation name since fedde239dc,
and so we can now simply inline the target method for each operation
2020-10-07 11:12:02 +09:00
Akira Matsuda 87dfa8617c attr_reader methods are public methods 2020-10-07 11:12:01 +09:00
Rafael Mendonça França 0c8df42b50
Decorate Rails' backtrace cleaner before passing to minitest
The minitest database cleaner never returns empty traces so we need to
make sure ours also have the same behavior before passing to minitest.
2020-10-07 00:28:02 +00:00
Rodrigo Ramírez Norambuena 3b9f5e3f4b Remove add_gem_entry_filter from GeneratorAppBase:
The add_gem_entry_filter was introduce in
f7e0758714 and doesn't work this
feature
2020-09-29 16:49:17 -03:00
Rodrigo Ramírez Norambuena bb69d1967f Remove gemfile_entry from GeneratorAppBase:
This private method is not in used. It's introduced in 3f2230b but at the
moment there not sense to keeping this code.
2020-09-29 16:36:04 -03:00
Eileen M. Uchitelle 5abe09bba7
Merge pull request #40213 from dbussink/allow-setting-digest-class
Add an ActiveSupport option to allow setting a digest class
2020-09-23 12:09:27 -04:00
Dirkjan Bussink 0f6c9bc786
Add an ActiveSupport option to allow setting a digest class
Right now it's already possible to set a digest class manually, but this
is not through a publicly supported and approved API. With these
configuration options, it is possible to configure a digest class to use
for digests inside Rails.

The reason for this is that it allows configuring other classes in
certain conditions like running in FIPS mode. FIPS disallows MD5 and
discourages SHA1. Even though this isn't used in Rails for security
related things, using newer hash algorithms means not having to explain
it to auditors which always makes life easier.

That's not the only reason though. If today Ruby is built and running
for example in an Ubuntu 18.04 FIPS approved environment, the default
Digest classes break, see https://bugs.ruby-lang.org/issues/13681 as
well.

By allowing a class to be configured, the following can be used so that
things work properly (using the new API proposed here):

```
Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
```

This would then use the OpenSSL certified FIPS implementation as well.
2020-09-23 17:47:35 +02:00
Kevin Deisz da39688e26
Create a gitattributes file for templated apps
.gitattributes files are a useful way to mark certain metadata about paths in a git repository (https://git-scm.com/docs/gitattributes). This can include all kinds of information, but one of the more useful ones is that linguist (https://github.com/github/linguist, the tool that powers the language statistics/diff view of GitHub) respects certain attributes. For example:

* `linguist-vendored` paths will not be counted toward the language statistics
* `linguist-generated` paths will not have their diff shown by default

These little niceties can be really helpful over time, so we should add it to the default app generator.
2020-09-23 10:24:27 -04:00
Paul Keen 133805f1f9 Uncomment bin/yarn in bin/setup for webpacker by default
By adding installing of webpacker, `bin/setup` requires manual update in order to do cold setup. This adds extra steps to generate app and setup it.
2020-09-22 22:01:40 +03:00
Rafael Mendonça França 7307994011
Make sure log level in development is debug
Laso make sure the tests are actually checking the log level of the app,
not the one we set in the test helper.
2020-09-22 16:12:38 +00:00
Eric Payne 229fd2a02f
Change the default log level from :debug to :info
I recently learned that Rails logs at the :debug level (not the :info
level) by default in production environments. This is a surprising
behaviour, as other popular frameworks do not log at this level
by default. It would not be surprising if a developer accidentally
logged personally identifiable information (PII) in a production
environment due to this behaviour.

I noticed that [in 2014](https://github.com/rails/rails/pull/16622), the
Rails project made an intentional decision to set the default log level
to :debug. However, the landscape around logging PII has changed since
then with the introduction of legislation like GDPR, so I thought it
prudent to reopen this discussion.
2020-09-22 15:04:44 +00:00
Ryuta Kamizono c848baffd2 ✂️ [ci skip]
895134bcff (diff-7789e18ec0a61c6845755a257e6eb34fR3)
ee9e308f68 (diff-5e9551294914b338d923032fa904c6beR103)
5f63c771f7 (diff-600d5368b55e46ed961abb4295977ac3R506)
48b6bacbc5 (diff-279ac5c088a3ee7e9f954bbc10d1b773R246)
49adb7f4c6 (diff-0cbe7171fdd7821fd5836896849141c0R111)
9bfe89e68e (diff-9c1c95b001e3680ba8a473cf23508b68R8)
a0f18e6090 (diff-bef0ae2c16dacf77bfd2ba099af8a330R47)
8b4d344815 (diff-09660f59aee7ec893ad609315e8843c5R18)
49d1b5a98d (diff-531e71a9d5fdc8181f38ce4416553694R107)
b674f04756 (diff-7521c0bb452244663b689e77658e63e3R98)
a9012af688 (diff-60bdcf1e1954ec56d41fc4c7bd8d3e39R512)
6380aee182 (diff-5158c234d5e19bb1cffadcbc088400f1R262)
c7820d8124 (diff-f4614e7ba8081c0c9e20fe64b6374228R60)
8df7ed3b88 (diff-0495ed68f82d1bbde593ab5491eab24aR169)
6f94260ac6 (diff-7ecb6672f3fd37dfb79c4539395d3857R28)
03e44f9300 (diff-e9234c4c6668852448059c0a35840bcaR185)
2020-09-16 09:52:10 +09:00
Vlado Cingel d556c99687 Uniform paths joining in the code generated by `rails new` 2020-09-11 10:34:43 +02:00
Jonathan Hefner be5eeb1a06 Load Rails tasks for each new Rake::Application
Follow-up to #40143.

Rails Rake tasks are loaded for each new `Rake::Application` instance
via `Rails.application.load_tasks`.  However, under the hood,
`Rails.application.load_tasks` used `require` instead of `load`, which
caused Rails tasks to be loaded for only the first `Rake::Application`
instance.

This commit changes the relevant `require` to `load`.

Fixes #40184.
2020-09-06 14:40:14 -05:00
Haroon Ahmed 3119672411 Prefer bin/rails for the credentials command 2020-09-02 21:03:56 +01:00
Xavier Noria 94ba417ece Move TruffleRuby check to select the autoloading mode to 6.1 defaults 2020-08-31 20:12:26 +02:00
Eugene Kenny 3d9af5a723
Merge pull request #40143 from jonathanhefner/load-rails-rake-tasks-once
Load Rails Rake tasks only once
2020-08-30 22:28:37 +01:00
Jonathan Hefner 85c5e82935 Load Rails Rake tasks only once
In #39137, a new `Rake::Application` instance was created per Rake
command invocation.  To ensure that the Rails tasks were defined for
each `Rake::Application`, `rails/tasks.rb` was loaded per instance.
However, `Rake::Application#load_rakefile` loads the application's
Rakefile, which should invoke `Rails.application.load_tasks`, which, in
turn, also loads the Rails tasks.  When a Rake task is defined more than
once, all definition blocks are executed when the task is run.  Hence,
Rails task blocks were being executed twice.

This commit removes the unnecessary load and avoids double execution.

Fixes #40136.
2020-08-30 11:34:26 -05:00
Benoit Daloze a011422bc2 Enable Zeitwerk by default on TruffleRuby 2020-08-30 13:48:08 +02:00
Adrianna Chang 55a668db29 Remove references to secrets.yml from documentation 2020-08-26 14:59:26 -04:00
Adrianna Chang e0637a5a50 Add attr_writer for credentials to Rails::Application 2020-08-26 13:30:29 -04:00
Jack McCracken 7459672fb0 Allow a proc to be used in addition to a static value for cookies_same_site_protection
Add documentation of Proc usage for SameSite property to configuring.md

Address PR comments

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
2020-08-25 14:33:48 -04:00
Gregorio Kusowski ee117650e1 Bump minimum web-console version to 4.0.3 2020-08-20 10:45:00 +02:00
Eileen M. Uchitelle 9a36b50b84
Merge branch 'master' into combine-structure-and-schema-tasks 2020-08-17 08:47:51 -04:00
Daniel Colson be2fd61137
Use deep_symbolize_keys instead of symbolize_names
Fixes #40031

While removing deprecated non-symbol access to nested `config_for`
hashes in #37876, we also broke `config_for` for anyone using the
[safe_yaml] gem. The problem is that `safe_yaml` patches `YAML.load` in
a way that doesn't honor the `symbolize_names` options (I believe this
is on purpose, to prevent symbol-based DOS attacks).

In the description of #37876 there is mention of the fact that this was
the first place in Rails we used `symbolize_names`, and that
`deep_symbolize_keys` had been used in the past.

This commit switches over to `deep_symbolize_keys` to allow `config_for`
to continue working for people using [safe_yaml].

[safe_yaml]: https://rubygems.org/gems/safe_yaml
2020-08-14 23:48:16 -04:00
Eugene Kenny e53f5ff730
Merge pull request #39851 from piecehealth/engine_skip_mailers
--skip-action-mailer option doesn't work for "rails plugin new"
2020-08-04 20:13:19 +01:00
piecehealth 1f2d0120c0 --skip-action-mailer and --skip-active_job option doesn't work for `rails plugin new project_name --full` or `rails plugin new project_name --mountable` 2020-08-04 10:48:34 +08:00
fatkodima 5488686851 Combine and deprecate `rails db:structure:{dump,load}` tasks into `rails db:schema:{dump,load}` 2020-08-03 19:08:41 +03:00
Jonathan Hefner f24347031f Load plugin VERSION constant by default
For example, for a plugin like `my_plugin`, this makes the
`MyPlugin::VERSION` constant available to all consumers by default.

This commit also replaces the default generated test with a test that
the developer is less likely to delete.
2020-07-31 15:43:34 -05:00
Jonathan Hefner 0098088fc1 Follow naming conventions in generated plugin test
This commit ensures that a generated test file like "foo/bar_test.rb"
defines the class `Foo::BarTest` rather than `Foo::Bar::Test`.
2020-07-31 10:01:48 -05:00
Eugene Kenny 4560c36da2
Merge pull request #39933 from exterm/engines-are-not-applications
Correct engine generator docs
2020-07-28 23:19:05 +01:00
Jonathan Hefner adfa417fbb Use standard config/application.rb in plugin dummy
The `config/application.rb` file of a plugin test dummy app should be
the same as in a standard Rails app, with the exception of an additional
`require` statement to load the plugin itself.  However, prior to this
commit, the plugin generator used a specialized template for a portion
of this file, which tended to drift out-of-sync with the standard app
generator's template.  Specifically, this drift could result in missing
`require` statements of newer Rails frameworks when the plugin generator
was run with any `--skip-xxxx` option.

This commit changes the plugin generator to insert its additional
`require` statement into the standard `config/application.rb` file
generated by the app generator.
2020-07-28 14:33:40 -05:00
Philip Müller dee804345d
[ci skip] Correct engine generator docs
Engines are not applications, indeed 'Application < Engine', so it's the other way round.
The difference can be confusing anyway, so we should make sure the documentation is clear.
2020-07-27 10:22:29 -04:00
Eugene Kenny c418fb9fe9
Merge pull request #39708 from jonathanhefner/finish_template-goes-last
Ensure principle tasks go before finish_template
2020-07-18 23:49:24 +01:00
Petrik f72294fdc0 Raise if camelcase inflection impossible in generator
When passing a camelcased model name to a generator sometimes it's
impossible to inflect the casing.  For example "BFF" will generate a
route for the controller BffsController, but the controller generated is
BfFsController.

The casing is impossible to inflect if both:
- a camelcased model name is passed to a generator
- `name.pluralize.underscore.singularize != name.underscore.singularize`

If this happens we raise an error. The error message explains the user
can either us an underscored name or add an inflection instead.
2020-07-13 22:02:13 +02:00
Guo Xiang Tan 85316f7bbe
Remove `protect_from_forgery` in rails plugin template.
`protect_from_forgery` is added to `ActionController::Base` by default
since ec4a836919
2020-07-13 14:39:30 +08:00
Guo Xiang Tan f1e53be508
Change default HTTP status to 308 for ActionDispatch::SSL.
308 status code introduced in https://tools.ietf.org/html/rfc7538
preserves the request method unlike 301 status code which would convert
POST requests to GET.
2020-07-06 14:51:24 +08:00
Jean Boussier 12f3f11f61 Use URI::DEFAULT_PARSER rather than instantiate a new one 2020-06-29 23:06:34 +02:00
Jonathan Hefner a6e1be7148 Ensure principle tasks go before finish_template
This fixes a regression of #13637, and adds a regression test.
2020-06-23 23:31:47 -05:00
Javan Makhmali 664e94989e
Merge pull request #39521 from rossta/patch/use-import-syntax-in-application-js-template
Use ES module import syntax in application js template
2020-06-18 07:43:09 -04:00
Ross Kaffenberger 04cbaa1475 Use ES module syntax for application.js.tt and docs
This change swaps the CommonJS require() syntax in the Webpacker
application.js pack template file and in documentation examples with ES
module import syntax.

Benefits of this change include:

Provides continuity with the larger frontend community: Arguably, one of
the main draws in adopting Webpacker is its integration with Babel to
support ES module syntax. For a fresh Rails install with Webpacker, the
application.js file will be the first impression most Rails developers
have with webpack and Webpacker.  Most of the recent documentation and
examples they will find online for using other libraries will be based
on ES module syntax.

Reduces confusion: Developers commonly add ES imports to their
application.js pack, typically by following online examples, which means
mixing require() and import statements in a single file. This leads to
confusion and unnecessary friction about differences between require()
and import.

Embraces browser-friendliness: The ES module syntax forward-looking and
is meant to be supported in browsers. On the other hand, require()
syntax is synchronous by design and not browser-supported as CommonJS
originally was adopted in Node.js for server-side JavaScript. That
webpack supports require() syntax is merely a convenience.

Encourages best practices regarding optimization: webpack can statically
analyze ES modules and "tree-shake", i.e., strip out unused exports from
the final build (given certain conditions are met, including
`sideEffects: false` designation in package.json).
2020-06-16 15:12:12 -04:00
Henrik Nyh 63824f9ffb
setup.tt comment: "at anytime" -> "at any time"
https://www.grammarly.com/blog/anytime-any-time/
2020-06-16 16:19:27 +01:00
Jonathan Hefner a6c958b3a7 Move Spring machinery to boot.rb
This partially reverts #39225, and folds `boot_with_spring.rb` into
`boot.rb`.

Fixes #39622.
2020-06-15 17:32:55 -05:00
Ryuta Kamizono 528b62e386 Address to false negative for Performance/DeletePrefix,DeleteSuffix
Follow up to c07dff7227.

Actually it is not the cop's fault, but we mistakenly use `^`, `$`, and
`\Z` in much places, the cop doesn't correct those conservatively.

I've checked all those usage and replaced all safe ones.
2020-06-14 13:04:47 +09:00
Josef Šimánek a49dfe38ae
Introduce Rails::TestUnitReporter.app_root to inject app_root when needed. 2020-06-14 00:02:49 +02:00
Josef Šimánek 32aebc76cb
Use COMPONENT_ROOT as app_root when present in test unit reporting. 2020-06-13 20:30:25 +02:00
Étienne Barrié cf3736dce8
Add application config for URL-safe Base64 CSRF tokens
This allows applications to safely upgrade to Rails 6.1 without
breaking tokens while the deploy is still being rolled out.
2020-06-11 11:39:37 -04:00
Kasper Timm Hansen 4654f4aab6
Merge pull request #39541 from jonathanhefner/silence-rake-task-backtraces
Silence Rake task backtraces
2020-06-05 12:54:11 +02:00
Jonathan Hefner 7ba531be74 Silence Rake task backtraces
Silence Rake task backtraces, similar to Rails::BacktraceCleaner.
Application lines are preserved, but all other lines are hidden.

This also affects unrecognized tasks, causing the backtrace to be hidden
entirely.  Closes #39524.

Co-authored-by: Petrik <petrik@deheus.net>
2020-06-05 02:26:46 -05:00
Ryuta Kamizono c07dff7227 Auto-correct for `delete_prefix`/`delete_suffix`
Follow up to #39409.
2020-06-05 12:40:39 +09:00
eileencodes 7b4fdf3ce7
Remove assumption that a primary config exists
Applications may not have a primary configuration so we should not
assume there is one. In both these cases we can get the right connection
without that.

For the databases.rake file we want to re-establish a connection for the
environment we're in. The first config defined under an environment for
a multi-db app will win. This is already the case on application boot so
we should be consistent.

For the info.rb file we already have a connection so we can lookup the
adapter from the connection's db_config. If a primary hadn't existed
this would have thrown an exception.

Followup to https://github.com/rails/rails/pull/39535 which removed the
assumption there was a primary config from the schema cache load
railtie.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-06-04 15:08:59 -04:00
Eugene Kenny 751d46af4f
Merge pull request #39523 from p8/rename-stubs-out-to-generate
Replace 'Stubs out' with 'Generates' in generator USAGE's [ci skip]
2020-06-03 10:40:40 +01:00
Petrik 2b09948637 Replace 'Stubs out' with 'Generates' in generator USAGE's [ci skip]
Generators generate things, but what is meant by 'Stubbing out' might
confuse beginners and non-native English speakers.
While generated tests are stubs that should have an implementation, a
generated model is a valid model that doesn't require any changes.
2020-06-03 08:51:47 +02:00
Haroon Ahmed 7a321d8429
rails new --minimal gives you a minimal rails stack. (#39282) 2020-06-02 13:29:02 -07:00
jasl 34adebd4a7 Don't inline run webpacker:install on rails new 2020-05-30 05:44:04 +08:00
Ryuta Kamizono c65864cdca Prefer no allocation `start/end_with?` over `String#[] ==` 2020-05-29 10:20:13 +09:00
Ryuta Kamizono dc94a753d1 require "active_support/core_ext/symbol/starts_ends_with" for Ruby 2.6
And use `Symbol#[]` to strip suffix to avoid intermediate string
allocation.
2020-05-25 05:24:44 +09:00
Jonathan Hefner a2ca8f062c Utilize Symbol#start_with? and #end_with?
Follow-up to #39155.

Thanks to Symbol#start_with? and #end_with?, these calls no longer need
to be prefixed with `.to_s`.
2020-05-24 14:46:12 -05:00
fatkodima e24d6ecbfd Update rubocop-performance gem and enable Performance/DeletePrefix and Performance/DeleteSuffix cops 2020-05-24 12:51:35 +03:00
Aaron Patterson 43ed3c7939
This is causing problems in master wrt backtraces
Before #39304 was merged, backtraces would look like this:

```
$ be ruby -I lib:test test/controller/request_forgery_protection_test.rb -n test_ignores_trailing_slash_during_generation
Run options: -n test_ignores_trailing_slash_during_generation --seed 22205

E

Error:
PerFormTokensControllerTest#test_ignores_trailing_slash_during_generation:
NoMethodError: undefined method `have_cookie_jar?' for #<Object:0x00007f9ce19b9620>
    /Users/aaron/git/rails/actionpack/lib/action_controller/test_case.rb:522:in `ensure in process'
    /Users/aaron/git/rails/actionpack/lib/action_controller/test_case.rb:542:in `process'
    /Users/aaron/git/rails/actionpack/lib/action_controller/test_case.rb:395:in `get'
    test/controller/request_forgery_protection_test.rb:1005:in `test_ignores_trailing_slash_during_generation'

rails test test/controller/request_forgery_protection_test.rb:1004

Finished in 0.213230s, 4.6898 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
```

After #39304 was merged they look like this:

```
$ be ruby -I lib:test test/controller/request_forgery_protection_test.rb -n test_ignores_trailing_slash_during_generation
Run options: -n test_ignores_trailing_slash_during_generation --seed 62892

E

Error:
PerFormTokensControllerTest#test_ignores_trailing_slash_during_generation:
NoMethodError: undefined method `have_cookie_jar?' for #<Object:0x00007fa6d60193c8>

rails test test/controller/request_forgery_protection_test.rb:1004

Finished in 0.211953s, 4.7180 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
```

This patch reverts the part of #39304 that removes the backtrace.
2020-05-20 08:42:36 -07:00
fatkodima 6c4f3be929 Unify raise_on_missing_translations for views and controllers 2020-05-20 02:42:59 +03:00
Rafael França a80115b7c5
Merge pull request #39204 from prathamesh-sonpatki/template-annotation
Add the configuration option for annotating templates with file names to the generated app
2020-05-19 19:11:31 -04:00
Prathamesh Sonpatki a673ce69e7
Rename `annotate_template_file_names` to `annotate_rendered_view_with_filenames`
- Add the configuration option for annotating templates with file names to the generated app.
- Add `annotate_rendered_view_with_filenames` option to configuring guide.
2020-05-19 09:28:14 +05:30
Vinicius Stock 98a3644be0
Create update yarn task (#39314)
* Use app:binstub:yarn in Action Text install generator
2020-05-17 19:51:32 +02:00
David Heinemeier Hansson f4c9d0b014
Add default ENV variable option with BACKTRACE to turn off backtrace cleaning (#39220)
* Add default ENV variable option with BACKTRACE to turn off backtrace cleaning when debugging framework code

* Use runner as the example

Although I think we should consider dropping -b in tests and just relying on this more general option for sidestepping the backtrace cleaner.
2020-05-17 08:52:05 -07:00
Xavier Noria 838d3f73dd The warning for autoloaded constants on boot includes a solution 2020-05-17 10:12:15 +02:00
Kasper Timm Hansen 03e82e2f0d
Merge pull request #39245 from paul-mannino/unload-app
Don't load app environment when running encrypted commands
2020-05-16 23:55:21 +02:00
David Heinemeier Hansson c6bdfd133f
Use explicit spring boot loader (#39225) 2020-05-16 13:57:45 -07:00
Ryan Davis d0060f1206 Fix failure in reporter_test.rb
I'm not sure about this one. The gist is, minitest's
UnexpectedError#message includes a backtrace but the reporter tests
here expect there not to be one in inline output.

Personally, I think that's wrong as it removes information you'd want
to debug, but this might be a philosophical difference with the rails
test ethos... or it might just be aesthetic.

I am happy to back out this change and fix the tests if you'd rather.
2020-05-15 16:42:27 -07:00
Haroon Ahmed 9c886c18bc fix wording in rail/engine class 2020-05-14 08:51:27 +01:00
Paul Mannino 4e8650f8b1 Don't load app environment when running encrypted commands
This extends the fix made by a39aa99c81 to the EncryptedCommand class
which suffers from the exact same issue.
2020-05-12 12:06:05 -05:00
Niklas Häusele 9488712365
Adds a rails test:all rake task (#39221)
* Adds a rails test:all rake task

This task runs all tests, including system tests.

* Better placement + slight tweak of the comment

Co-authored-by: David Heinemeier Hansson <david@loudthinking.com>
2020-05-10 17:22:49 -07:00
Ryuta Kamizono 1165401ee9 Remove unused `require "active_support/core_ext/kernel/singleton_class"`
`singleton_class` is in Ruby 1.9.2, and there is no use singleton class
eval in the files.
2020-05-10 03:20:02 +09:00
yuuji.yaginuma fde100d18e Add `config.generators.after_generate` for processing to generated files
Register a callback that will get called right after generators has
finished.

This is useful if users want to process generated files.
For example, can execute an autocorrect of RuboCop for generated files
as like following.

```ruby
config.generators.after_generate do |files|
  system("bundle exec rubocop --auto-correct " + files.join(" "), exception: true)
end
```
2020-05-08 21:06:04 +09:00
Kasper Timm Hansen f1c7a32e90
Merge pull request #39001 from jonathanhefner/test-runner-recognize-windows-paths
Recognize Windows-style paths in test runner
2020-05-07 22:48:23 +02:00
Kasper Timm Hansen d143154147
Merge pull request #39036
Closes #39036
2020-05-07 01:05:58 +02:00
Jorge Manrubia a0f18e6090
Make test file patterns configurable via Environment variables
This makes test file patterns configurable via two environment variables:
`DEFAULT_TEST`, to configure files to test, and `DEFAULT_TEST_EXCLUDE`,
to configure files to exclude from testing.

These values were hardcoded before, which made it difficult to add
new categories of tests that should not be executed by default (e.g:
smoke tests).

It uses environment variables instead of regular Rails config options
because Rails environment is not available when the Runner builds the
list of files to test (unless using Spring). A nicer solution would be
making sure that the Rails environment is always loaded when the runner
starts. This is a first simple step to make these paths configurable for
now

This way at least you could override defaults in `config/boot.rb`:

```ruby
ENV["DEFAULT_TEST_EXCLUDE"] = "test/{dummy,smoke,system}/**/*_test.rb
```

Co-authored-by: Jeremy Daer <jeremydaer@gmail.com>
2020-05-07 01:04:01 +02:00
Ryuta Kamizono 98a1405f07 Dogfooding "active_support/core_ext/symbol/starts_ends_with"
Any missing thing would be found such like #39159.
2020-05-06 14:19:25 +09:00
Ryuta Kamizono 3f883b69a7 Relax required rack-mini-profiler version 2.0.x to 2.x 2020-05-05 17:22:26 +09:00
Brandon Fish b4ccdcb73a Include parallelize :threads option when fork is not available 2020-05-04 20:26:24 -05:00
Jonathan Hefner 68a3f679d9 Support reentrant calls to RakeCommand.perform
Rake stores the current top-level task and arguments in global state.
Invoking another top-level task within the same process requires
overwriting this state.  Doing so indiscriminately can cause incorrect
behavior, such as infinitely repeating the original task.  In
particular, this is a problem when running one task from another via
`rails_command "...", inline: true`.

The solution is to save and restore the global state in each call to
`RakeCommand.perform` using the `Rake.with_application` method.

Fixes #39128.
2020-05-03 19:28:15 -05:00
Alberto Almagro 8bae32ba2c Add mention to shared section in `config_for` docs [ci skip]
37913 added the possibility to deeply merge configurations by grouping
them within a shared section. This powerful alternative was not reflected
in any documentation, which made my team think it was not possible until
I found out this feature after looking at the source code.

This patch reflects this change in the documentation so that it is
easier for other developers to know about this behavior.
2020-05-01 15:25:14 +02:00
Ryuta Kamizono ca3579ad29
Merge pull request #39064 from kamipo/pg-1.1
Update pg gem required version to 1.1
2020-05-01 09:19:30 +09:00
Xavier Noria 92d03850f3 files -> directories in zeitwerk:check warning [skip ci] 2020-04-29 11:12:46 +02:00
Xavier Noria cd2d1cf731
Merge pull request #38374 from peterb/improve_zeitwerk_check_warning_message
Improve zeitwerk:check warning message [CI skip]
2020-04-29 11:08:17 +02:00
Ryuta Kamizono 592358e182 Update pg gem required version to 1.1
This is required for #39063 to use `PG::TextDecoder::Numeric`.

Ref https://github.com/ged/ruby-pg/pull/25.

The pg gem 1.1.0 was released at August 24, 2018, so I think it is good
timing to bump the required version for improving and cleaning up the
code base.

https://rubygems.org/gems/pg/versions
2020-04-27 16:27:40 +09:00
Tasos Latsas 603403417e Remove redundant begin block from yarn template 2020-04-27 08:32:42 +03:00
Eugene Kenny c8c549750d Require time core extensions in all environments
These have been required in the generated test environment config since
1c7207a22f, but the generated development
config also uses them (albeit inside a conditional), and the generated
production config contains a comment which uses them.

More generally, we shouldn't require core extensions in one environment
and not others, since applications with `config.active_support.bare`
enabled could rely on them implicitly and exhibit inconsistent behaviour
across environments.
2020-04-26 22:25:14 +01:00
Jonathan Hefner 7bf4520292 Recognize Windows-style paths in test runner
Previously, a test runner argument had to contain a forward slash to be
recognized as a path.  Now, backslashes will also be considered,
enabling the use of Windows-style paths.

Fixes #38243.
2020-04-21 00:48:16 -05:00
Eugene Kenny cb7b1ea8c8 Add retry_jitter to 6.1 new framework defaults
This was added to the defaults for new applications in
e2cdffce3d, but we also need an entry in
the new framework defaults initializer for upgrading applications.
2020-04-19 23:53:20 +01:00
Eugene Kenny a254922efa Don't gitignore tmp/pids/.keep
Since 04cfbc807f, a keepfile is generated
in `tmp/pids/` to ensure that the directory always exists. However, the
gitignore pattern for `/tmp/*` meant it wasn't tracked in git.

To override that pattern we have to allow the `tmp/pids/` directory,
ignore everything inside it, then finally allow `tmp/pids/.keep` again.
2020-04-16 22:51:51 +01:00
Ryuta Kamizono 99a4620a19
Merge pull request #38923 from kamipo/remove_dead_test_code
Remove dead test code for unsupported adapters
2020-04-15 00:02:34 +09:00
Rafael França 6f6f4e40ab
Merge pull request #36125 from lulalala/doc-for-model-errors
Document update for ActiveModel#errors
2020-04-13 14:11:55 -04:00
Ryuta Kamizono f960948d23 Remove more code for unsupported frontbase and ibm_db adapters
FrontBase and IBM_DB adapters do not work for Rails 5.2.

https://rubygems.org/gems/ruby-frontbase
https://rubygems.org/gems/ibm_db
2020-04-12 11:45:28 +09:00
Haroon Ahmed 6504e97561 update global rails commands to bundled rails i.e. bin/rails 2020-04-11 17:32:26 +01:00
Kasper Timm Hansen 4174f56b6c
Merge pull request #38574 from jonathanhefner/plugin-remove-rdoc-rake-task
Remove :rdoc Rake task in generated plugin
2020-04-05 23:38:21 +02:00
Jonathan Hefner 85808bf177 Clarify database.yml DATABASE_URL instructions
From the instructions in database.yml, it is not clear that Rails will
automatically use ENV['DATABASE_URL'] if it is present.

This commit rewords the instructions to clarify that Rails will do so.
2020-04-04 15:42:09 -05:00
Jonathan Hefner 677eac678d Remove `rake rdoc` task in generated plugin
The `rdoc lib` command produces nearly the same output as `rake rdoc`.
The `rdoc lib` command also has the benefit of being standard, whereas
Rake subcommands can vary from project to project.  Since the purpose of
either command is to support local development, as opposed to generating
official docs for consumption by e.g. rubygems, the standard command
seems preferable.

Note that the `rdoc` command outputs to the doc/ directory by default,
so this commit also adds that directory to the plugin .gitignore file.
2020-04-04 13:15:16 -05:00
Eugene Kenny 775148c837 Allow utc_to_local_returns_utc_offset_times to be set in new_framework_defaults_6_1.rb
Enabling this option in new_framework_defaults_6_1.rb didn't work
before, as railtie initializers run before application initializers.
2020-04-03 19:41:35 +01:00
David Heinemeier Hansson 3e0cdbeaf4
require, require_relative, load by double quotes (#38841)
* require, require_relative, load by double quotes

We're getting rid of all single quote usage, unless it serves a specific purpose, as per the general style guide.
2020-03-29 16:30:52 -07:00
Kasper Timm Hansen bf34c808f9
Merge branch 'tzinfo2' 2020-03-28 20:53:24 +01:00
Phil Ross e9425abe33
Update to TZInfo v2.0.0
Co-authored-by: Jared Beck <jared@jaredbeck.com>
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-03-28 20:42:43 +01:00
Eugene Kenny 326d502714 Handle paths with trailing slashes in rails test
The `rails test` command scans its arguments for test paths to load
before handing off option parsing to Minitest. To avoid incorrectly
interpreting a `-n /regex/` pattern as an absolute path to a directory,
it skips arguments that end with a slash. However a relative path ending
in a slash is not ambiguous, so we can safely treat those as test paths.

This is especially useful in bash, where tab completing a directory
leaves a trailing slash in place.
2020-03-26 21:48:17 +00:00
Carlos Antonio da Silva 104aaf5b3f Test with and generate new apps with webpacker 5.0 2020-03-22 16:39:01 -03:00
Kasper Timm Hansen 54cb01610e
Merge pull request #38495 from jonathanhefner/isolate-argv-in-command-invoke
Isolate ARGV in Rails::Command.invoke
2020-03-14 02:47:22 +01:00
Rodrigo Ramírez Norambuena 695dc5f984 Quotation mark for gems with options in Gemfile template:
Use the same quote (') for gems with extra options used by  AppGenerator
in the Gemfile template.
2020-03-13 02:10:00 -03:00
Aaron Patterson 690d946db9
Rails::Command.invoke wants kwargs, so give it kwargs
This fixes an exception when generating a new app on Ruby 2.8.  Before
this commit, I get this exception:

```
$ be ruby railties/exe/rails new ~/git/fix-bug --dev
...
...
Traceback (most recent call last):
	31: from railties/exe/rails:10:in `<main>'
	30: from railties/exe/rails:10:in `require'
	29: from /Users/aaron/git/rails/railties/lib/rails/cli.rb:18:in `<top (required)>'
	28: from /Users/aaron/git/rails/railties/lib/rails/command.rb:45:in `invoke'
	27: from /Users/aaron/git/rails/railties/lib/rails/command/base.rb:69:in `perform'
	26: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	25: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	24: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	23: from /Users/aaron/git/rails/railties/lib/rails/commands/application/application_command.rb:26:in `perform'
	22: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
	21: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/group.rb:232:in `dispatch'
	20: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `invoke_all'
	19: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `map'
	18: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `each'
	17: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `block in invoke_all'
	16: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	15: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	14: from (eval):1:in `run_webpack'
	13: from /Users/aaron/git/rails/railties/lib/rails/generators/app_base.rb:419:in `run_webpack'
	12: from /Users/aaron/git/rails/railties/lib/rails/generators/actions.rb:255:in `rails_command'
	11: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/actions.rb:197:in `in_root'
	10: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/actions.rb:187:in `inside'
	 9: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.8.0/fileutils.rb:139:in `cd'
	 8: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.8.0/fileutils.rb:139:in `chdir'
	 7: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/actions.rb:187:in `block in inside'
	 6: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.8.0/gems/thor-1.0.1/lib/thor/actions.rb:197:in `block in in_root'
	 5: from /Users/aaron/git/rails/railties/lib/rails/generators/actions.rb:256:in `block in rails_command'
	 4: from /Users/aaron/git/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:15:in `silence_warnings'
	 3: from /Users/aaron/git/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:28:in `with_warnings'
	 2: from /Users/aaron/git/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:15:in `block in silence_warnings'
	 1: from /Users/aaron/git/rails/railties/lib/rails/generators/actions.rb:257:in `block (2 levels) in rails_command'
/Users/aaron/git/rails/railties/lib/rails/command.rb:31:in `invoke': wrong number of arguments (given 3, expected 1..2) (ArgumentError)
```

After this commit, things seem to work.
2020-03-12 10:04:56 -07:00
OsamaSayegh ac1d4a6a62 Include rack-mini-profiler gem by default 2020-03-11 18:47:50 +03:00
Nate Berkopec 670026737b
Fix exceptions raised/rescued in dev by IPAddr
Putting ".localhost" at the end causes 4 IPAddr::InvalidAddressError
exceptions to be raised and rescued during every request when the
HostAuthorization middleware attempts to compare an IPAddr with a
"localhost" string.
2020-03-10 12:40:23 -06:00
Charles Oliver Nutter 09e0372532
Use optimized subclass of StringInquirer for Rails.env
This adds a StringInquirer subclass EnvironmentInquirer that
predefines the three default environments as query methods, in
order to avoid dispatching through `method_missing` for every call
to those methods. The original StringInquirer was not modified due
to the side effects of having new env-related methods on it. This
new class was not implemented using lazy method definition to
avoid the open-ended possibility of defining a new method for all
query calls. The three default environments should cover a high
percentage of real-world uses, and users with custom environments
could add their own to this class.

Fixes #37803.
2020-03-05 14:57:27 -06:00