From 2e5ec9a6efc80fd266b974fc50b2775afa73130b Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Mon, 10 Jun 2019 16:46:52 +0100 Subject: Allow using env var to specify pidfile Previously it was only possible to specify the location of the pidfile for the 'rails server' command with the '-P' flag. This adds support for specifying the pidfile using a PIDFILE env var, which can still be overridden by the '-P' flag and with the default pidfile path unchanged. The motivation for this feature comes from using Docker to run multiple instances of the same rails app. When developing a rails app with Docker, it's common to bind-mount the rails root directory in the running container, so that changes to files are shared between the container and the host. However, this doesn't work so well with the pidfile and it's necessary to (remember to) add a '-P' flag to the 'rails server' command line; being able to specify this flag using an env var would make developing with Rails+Docker a bit simpler. --- guides/source/initialization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/initialization.md b/guides/source/initialization.md index 817c6b17bc..c19b2cffc5 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -289,7 +289,7 @@ def default_options environment: (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup, daemonize: false, caching: nil, - pid: Options::DEFAULT_PID_PATH, + pid: ENV.fetch("PIDFILE", Options::DEFAULT_PIDFILE).dup, restart_cmd: restart_command) end ``` -- cgit v1.2.3 From ddb6d788d6a611fd1ba6cf92ad6d1342079517a8 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 15 Jun 2019 12:54:26 +0900 Subject: Make `ActionDispatch::Response#content_type` behavior configurable I changed return value of `ActionDispatch::Response#content_type` in #36034. But this change seems to an obstacle to upgrading. https://github.com/rails/rails/pull/36034#issuecomment-498795893 Therefore, I restored the behavior of `ActionDispatch::Response#content_type` to 5.2 and deprecated old behavior. Also, made it possible to control the behavior with the config. --- guides/source/configuring.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index b0bfe72741..ffff9417b9 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -553,6 +553,10 @@ Defaults to `'signed cookie'`. Any exceptions that are not configured will be mapped to 500 Internal Server Error. +* `config.action_dispatch.return_only_media_type_on_content_type` change the + return value of `ActionDispatch::Response#content_type` to the Content-Type + header without modification. Defaults to `false`. + * `ActionDispatch::Callbacks.before` takes a block of code to run before the request. * `ActionDispatch::Callbacks.after` takes a block of code to run after the request. @@ -908,6 +912,7 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla - `config.autoloader`: `:zeitwerk` - `config.action_view.default_enforce_utf8`: `false` - `config.action_dispatch.use_cookies_with_metadata`: `true` +- `config.action_dispatch.return_only_media_type_on_content_type`: `false` - `config.action_mailer.delivery_job`: `"ActionMailer::MailDeliveryJob"` - `config.active_job.return_false_on_aborted_enqueue`: `true` - `config.active_storage.queues.analysis`: `:active_storage_analysis` -- cgit v1.2.3 From 58256db50750781016f5ea6d2dd6cbc72096062b Mon Sep 17 00:00:00 2001 From: Aaron Suarez Date: Sun, 23 Jun 2019 20:13:11 -0500 Subject: Update link to OWASP XSS cheat sheet [ci skip] --- guides/source/security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/security.md b/guides/source/security.md index 22c122d4b9..5bb7a51524 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -1211,4 +1211,4 @@ The security landscape shifts and it is important to keep up to date, because mi * Subscribe to the Rails security [mailing list](https://groups.google.com/forum/#!forum/rubyonrails-security). * [Brakeman - Rails Security Scanner](https://brakemanscanner.org/) - To perform static security analysis for Rails applications. * [Keep up to date on the other application layers](http://secunia.com/) (they have a weekly newsletter, too). -* A [good security blog](https://www.owasp.org) including the [Cross-Site scripting Cheat Sheet](https://www.owasp.org/index.php/DOM_based_XSS_Prevention_Cheat_Sheet). +* A [good security blog](https://www.owasp.org) including the [Cross-Site scripting Cheat Sheet](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.md). -- cgit v1.2.3 From 1466701fab446fac109908962b3a7af4443f44db Mon Sep 17 00:00:00 2001 From: Tatsuya Hoshino Date: Tue, 25 Jun 2019 23:20:19 +0900 Subject: Replace the www.robotstxt.org URL with https one [ci skip] The robots.txt site is moved permanently to https URL. --- guides/source/configuring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index ffff9417b9..e53e8b4e92 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1541,7 +1541,7 @@ Disallow: / ``` To block just specific pages, it's necessary to use a more complex syntax. Learn -it on the [official documentation](http://www.robotstxt.org/robotstxt.html). +it on the [official documentation](https://www.robotstxt.org/robotstxt.html). Evented File System Monitor --------------------------- -- cgit v1.2.3 From c3a08f8844e5c11f80733e211da9fd0c13a5829a Mon Sep 17 00:00:00 2001 From: dineshpanda Date: Wed, 26 Jun 2019 03:07:50 +0530 Subject: [ci skip] Refer actionmailbox and actiontext in the guide --- guides/source/initialization.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'guides') diff --git a/guides/source/initialization.md b/guides/source/initialization.md index c19b2cffc5..556c85cc0f 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -108,6 +108,8 @@ A standard Rails application depends on several gems, specifically: * activerecord * activestorage * activesupport +* actionmailbox +* actiontext * arel * builder * bundler @@ -538,6 +540,8 @@ require "rails" action_mailer/railtie active_job/railtie action_cable/engine + action_mailbox/engine + action_text/engine rails/test_unit/railtie sprockets/railtie ).each do |railtie| -- cgit v1.2.3 From 1518ce3dc8dc092a32cf1020ff7c67f2337b3993 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Thu, 27 Jun 2019 11:53:46 +0900 Subject: [ci skip] Update free-programming-books link in getting started guide https://github.com/vhf/free-programming-books seems to have moved to https://github.com/EbookFoundation/free-programming-books --- guides/source/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 64f4a3b6b3..ce45dbb2a7 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -28,7 +28,7 @@ curve diving straight into Rails. There are several curated lists of online reso for learning Ruby: * [Official Ruby Programming Language website](https://www.ruby-lang.org/en/documentation/) -* [List of Free Programming Books](https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#ruby) +* [List of Free Programming Books](https://github.com/EbookFoundation/free-programming-books/blob/master/free-programming-books.md#ruby) Be aware that some resources, while still excellent, cover versions of Ruby as old as 1.6, and commonly 1.8, and will not include some syntax that you will see in day-to-day -- cgit v1.2.3 From 89afd816bdf8e5625237891c2ff0ac2db71ea5d6 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 29 Jun 2019 08:35:23 +0900 Subject: Link to top of PR as well as other links [ci skip] --- guides/source/6_0_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/6_0_release_notes.md b/guides/source/6_0_release_notes.md index c826b19f1a..c152076628 100644 --- a/guides/source/6_0_release_notes.md +++ b/guides/source/6_0_release_notes.md @@ -513,7 +513,7 @@ Please refer to the [Changelog][active-record] for detailed changes. ([Pull Request](https://github.com/rails/rails/pull/34742)) * Add the ability to disable scopes generated by `ActiveRecord.enum`. - ([Pull Request](https://github.com/rails/rails/pull/34605/files)) + ([Pull Request](https://github.com/rails/rails/pull/34605)) * Make implicit ordering configurable for a column. ([Pull Request](https://github.com/rails/rails/pull/34480)) -- cgit v1.2.3 From 49073faa9217b5b3115cfde5b0de072dd8271cd3 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 30 Jun 2019 23:50:38 +0200 Subject: adds two sections to the upgrading notes for autoloading [skip ci] --- guides/source/upgrading_ruby_on_rails.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'guides') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 54f014293d..4192063e9b 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -270,6 +270,16 @@ In that case, `app/models/concerns` is assumed to be a root directory (because i The `Concerns::` namespace worked with the classic autoloader as a side-effect of the implementation, but it was not really an intended behavior. An application using `Concerns::` needs to rename those classes and modules to be able to run in `zeitwerk` mode. +#### Having `app` in the autoload paths + +Some projects want something like `app/api/base.rb` to define `API::Base`, and add `app` to the autoload paths to accomplish that in `classic` mode. Since Rails adds all subdirectories of `app` to the autoload paths automatically, we have another situation in which there are nested root directories, so that setup no longer works. Similar principle we explained above with `concerns`. + +If you want to keep that structure, you'll need to delete the subdirectory from the autoload paths in an initializer: + +```ruby +ActiveSupport::Dependencies.autoload_paths.delete("#{Rails.root}/app/api") +``` + #### Autoloaded Constants and Explicit Namespaces If a namespace is defined in a file, as `Hotel` is here: @@ -391,6 +401,12 @@ To fix this, just remove the wildcards: config.autoload_paths << "#{config.root}/lib" ``` +#### Eager loading and autoloading are consistent + +In `classic` mode, if `app/models/foo.rb` defines `Bar`, you won't be able to autoload that file, but eager loading will work because it loads files recursively blindly. This can be a source of errors if you test things first eager loading, execution may fail later autoloading. + +In `zeitwerk` mode both loading modes are consistent, they fail and err in the same files. + #### How to Use the Classic Autoloader in Rails 6 Applications can load Rails 6 defaults and still use the classic autoloader by setting `config.autoloader` this way: -- cgit v1.2.3 From 63a863476ae4bcf2ddc15a8c112abfe58abf6a15 Mon Sep 17 00:00:00 2001 From: Michael R Fleet Date: Mon, 1 Jul 2019 13:47:53 -0400 Subject: use 'template' instead of 'create_file' for erb templates in generators guide [skip ci] --- guides/source/generators.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/generators.md b/guides/source/generators.md index 88ce4be8da..cd8fbede17 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -252,7 +252,7 @@ Add the method below, so our generator looks like the following: # lib/generators/rails/my_helper/my_helper_generator.rb class Rails::MyHelperGenerator < Rails::Generators::NamedBase def create_helper_file - create_file "app/helpers/#{file_name}_helper.rb", <<-FILE + template "app/helpers/#{file_name}_helper.rb", <<-FILE module #{class_name}Helper attr_reader :#{plural_name}, :#{plural_name.singularize} end @@ -307,7 +307,7 @@ To do that, we can change the generator this way: # lib/generators/rails/my_helper/my_helper_generator.rb class Rails::MyHelperGenerator < Rails::Generators::NamedBase def create_helper_file - create_file "app/helpers/#{file_name}_helper.rb", <<-FILE + template "app/helpers/#{file_name}_helper.rb", <<-FILE module #{class_name}Helper attr_reader :#{plural_name}, :#{plural_name.singularize} end -- cgit v1.2.3 From 41503f3d08418fb2dfe0eb85ac797059d9590051 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 2 Jul 2019 11:24:43 +0900 Subject: Revert "Merge pull request #36582 from f1337/master" This reverts commit 60e19c6d6cb60159af4e2247f29d2cea375a21d6, reversing changes made to 72e257b4c935b6829f7d4db36dea61a1682aa44e. The method signature is different between `create_file` and `template`. https://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#create_file-instance_method https://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#template-instance_method --- guides/source/generators.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/generators.md b/guides/source/generators.md index cd8fbede17..88ce4be8da 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -252,7 +252,7 @@ Add the method below, so our generator looks like the following: # lib/generators/rails/my_helper/my_helper_generator.rb class Rails::MyHelperGenerator < Rails::Generators::NamedBase def create_helper_file - template "app/helpers/#{file_name}_helper.rb", <<-FILE + create_file "app/helpers/#{file_name}_helper.rb", <<-FILE module #{class_name}Helper attr_reader :#{plural_name}, :#{plural_name.singularize} end @@ -307,7 +307,7 @@ To do that, we can change the generator this way: # lib/generators/rails/my_helper/my_helper_generator.rb class Rails::MyHelperGenerator < Rails::Generators::NamedBase def create_helper_file - template "app/helpers/#{file_name}_helper.rb", <<-FILE + create_file "app/helpers/#{file_name}_helper.rb", <<-FILE module #{class_name}Helper attr_reader :#{plural_name}, :#{plural_name.singularize} end -- cgit v1.2.3 From d71d3f4326d07ef6ccb074b60ee7adaadadcb637 Mon Sep 17 00:00:00 2001 From: tr4b4nt Date: Tue, 2 Jul 2019 16:47:00 +0200 Subject: Replace replica with primary in automatic connection switching after write in multi-db docs [ci skip] Reads after write should be from the primary database. --- guides/source/active_record_multiple_databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_multiple_databases.md b/guides/source/active_record_multiple_databases.md index d7d9bd1ca9..07be21a254 100644 --- a/guides/source/active_record_multiple_databases.md +++ b/guides/source/active_record_multiple_databases.md @@ -180,7 +180,7 @@ to primary based on the HTTP verb and whether there was a recent write. If the application is receiving a POST, PUT, DELETE, or PATCH request the application will automatically write to the primary. For the specified time after the write the application -will read from the replica. For a GET or HEAD request the application will read from the +will read from the primary. For a GET or HEAD request the application will read from the replica unless there was a recent write. To activate the automatic connection switching middleware, add or uncomment the following -- cgit v1.2.3 From 8a0d1dfc0a94d7ea0d579d8d697f2c3ff9a0a0bf Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Wed, 3 Jul 2019 18:36:31 -0500 Subject: Update docs regarding skipping CI tests [ci skip] The phrasing of this struck we as odd, "To help our CI servers..." So I feel it would be more useful if we explain more explicitly that ci skip cuts down on usage by not running CI. --- guides/source/contributing_to_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index d3706a4dbf..f8649131a6 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -139,7 +139,7 @@ changes to the master branch. When working with documentation, please take into account the [API Documentation Guidelines](api_documentation_guidelines.html) and the [Ruby on Rails Guides Guidelines](ruby_on_rails_guides_guidelines.html). -NOTE: To help our CI servers you should add [ci skip] to your documentation commit message to skip build on that commit. Please remember to use it for commits containing only documentation changes. +NOTE: For documentation changes, your commit message should include [ci skip]. This will skip the running the test suite, helping us to cut down on our server costs. Keep in mind that you should only skip CI when your change touches documentation exclusively. Translating Rails Guides ------------------------ -- cgit v1.2.3 From 6fd43bd07170d54e90625081bf21c36d3666b8c6 Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Thu, 4 Jul 2019 10:46:44 -0500 Subject: Fix a typo by removing extra article [ci skip] --- guides/source/contributing_to_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index f8649131a6..9c28ff6a9c 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -139,7 +139,7 @@ changes to the master branch. When working with documentation, please take into account the [API Documentation Guidelines](api_documentation_guidelines.html) and the [Ruby on Rails Guides Guidelines](ruby_on_rails_guides_guidelines.html). -NOTE: For documentation changes, your commit message should include [ci skip]. This will skip the running the test suite, helping us to cut down on our server costs. Keep in mind that you should only skip CI when your change touches documentation exclusively. +NOTE: For documentation changes, your commit message should include [ci skip]. This will skip running the test suite, helping us to cut down on our server costs. Keep in mind that you should only skip CI when your change touches documentation exclusively. Translating Rails Guides ------------------------ -- cgit v1.2.3