From 31fe0ec28db495b955d76ffe75dcc04a5f7705e0 Mon Sep 17 00:00:00 2001 From: Cesar Carruitero Date: Tue, 16 May 2017 00:13:01 -0500 Subject: some typos and rephrasing in system test guide [ci skip] --- guides/source/testing.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index c0394f927e..0b5c880962 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -600,11 +600,8 @@ Model tests don't have their own superclass like `ActionMailer::TestCase` instea System Testing -------------- -System tests are full-browser tests that can be used to test your application's -JavaScript and user experience. System tests use Capybara as a base. - -System tests allow for running tests in either a real browser or a headless -driver for testing full user interactions with your application. +System tests allows test user interactions with your application, running tests +in either a real or a headless browser. System tests uses Capybara as base. For creating Rails system tests, you use the `test/system` directory in your application. Rails provides a generator to create a system test skeleton for you. @@ -669,8 +666,9 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase end ``` -If your Capybara configuration requires more setup than provided by Rails, all -of that configuration can be put into the `application_system_test_case.rb` file. +If your Capybara configuration requires more setup than provided by Rails, this +additional configuration could be added into `application_system_test_case.rb` +file. Please see [Capybara's documentation](https://github.com/teamcapybara/capybara#setup) for additional settings. @@ -693,9 +691,9 @@ take a screenshot of the browser. Now we're going to add a system test to our blog application. We'll demonstrate writing a system test by visiting the index page and creating a new blog article. -If you used the scaffold generator, a system test skeleton is automatically -created for you. If you did not use the generator start by creating a system -test skeleton. +If you used the scaffold generator, a system test skeleton was automatically +created for you. If you didn't use the scaffold generator, start by creating a +system test skeleton. ```bash $ bin/rails generate system_test articles -- cgit v1.2.3 From 9063007538ffdfb03d35c7bb75218dfd2ddfc56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Alberto=20Ch=C3=A1vez?= Date: Thu, 1 Jun 2017 14:58:42 -0500 Subject: SystemTesting::Driver can register capybara-webkit and poltergeist drivers. When using `driver_by` with capybara-webkit or poltergeist, SystemTesting::Driver will register the driver while passing `screen_size` and `options` parameteres. `options` could contain any option supported by the underlying driver. --- guides/source/testing.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index e4fc8c7b6e..21ceeced1d 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -660,8 +660,9 @@ end The driver name is a required argument for `driven_by`. The optional arguments that can be passed to `driven_by` are `:using` for the browser (this will only -be used by Selenium), and `:screen_size` to change the size of the screen for -screenshots. +be used by Selenium), `:screen_size` to change the size of the screen for +screenshots, and `:options` which can be used to set options supported by the +driver. ```ruby require "test_helper" -- cgit v1.2.3 From 116b70ca7d45f734b888073e847fec113e9f4a7f Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 3 Jun 2017 17:31:39 +0900 Subject: Change default application.js included in new Rails app [ci skip] --- guides/source/asset_pipeline.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 22b6b278d7..5d774566dd 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -447,15 +447,15 @@ For example, a new Rails application includes a default ```js // ... -//= require jquery -//= require jquery_ujs +//= require rails-ujs +//= require turbolinks //= require_tree . ``` In JavaScript files, Sprockets directives begin with `//=`. In the above case, the file is using the `require` and the `require_tree` directives. The `require` directive is used to tell Sprockets the files you wish to require. Here, you are -requiring the files `jquery.js` and `jquery_ujs.js` that are available somewhere +requiring the files `rails-ujs.js` and `turbolinks.js` that are available somewhere in the search path for Sprockets. You need not supply the extensions explicitly. Sprockets assumes you are requiring a `.js` file when done from within a `.js` file. -- cgit v1.2.3 From b6b0c99ff3e8ace3f42813154dbe4b8ad6a98e6c Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Wed, 31 May 2017 12:16:20 +0300 Subject: Use mattr_accessor default: option throughout the project --- guides/source/active_support_core_extensions.md | 8 +++----- guides/source/plugins.md | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 67bed4c8da..e34af8aa8d 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -940,8 +940,7 @@ The macros `cattr_reader`, `cattr_writer`, and `cattr_accessor` are analogous to ```ruby class MysqlAdapter < AbstractAdapter # Generates class methods to access @@emulate_booleans. - cattr_accessor :emulate_booleans - self.emulate_booleans = true + cattr_accessor :emulate_booleans, default: true end ``` @@ -950,8 +949,7 @@ Instance methods are created as well for convenience, they are just proxies to t ```ruby module ActionView class Base - cattr_accessor :field_error_proc - @@field_error_proc = Proc.new{ ... } + cattr_accessor :field_error_proc, default: Proc.new { ... } end end ``` @@ -963,7 +961,7 @@ Also, you can pass a block to `cattr_*` to set up the attribute with a default v ```ruby class MysqlAdapter < AbstractAdapter # Generates class methods to access @@emulate_booleans with default value of true. - cattr_accessor(:emulate_booleans) { true } + cattr_accessor :emulate_booleans, default: true end ``` diff --git a/guides/source/plugins.md b/guides/source/plugins.md index 760ff431c0..8c2d56ceb8 100644 --- a/guides/source/plugins.md +++ b/guides/source/plugins.md @@ -340,8 +340,7 @@ module Yaffle module ClassMethods def acts_as_yaffle(options = {}) - cattr_accessor :yaffle_text_field - self.yaffle_text_field = (options[:yaffle_text_field] || :last_squawk).to_s + cattr_accessor :yaffle_text_field, default: (options[:yaffle_text_field] || :last_squawk).to_s end end end @@ -411,8 +410,7 @@ module Yaffle module ClassMethods def acts_as_yaffle(options = {}) - cattr_accessor :yaffle_text_field - self.yaffle_text_field = (options[:yaffle_text_field] || :last_squawk).to_s + cattr_accessor :yaffle_text_field, default: (options[:yaffle_text_field] || :last_squawk).to_s include Yaffle::ActsAsYaffle::LocalInstanceMethods end -- cgit v1.2.3 From 7892b717a801e40ee4db1ac6622d844ae6998132 Mon Sep 17 00:00:00 2001 From: Joe Francis Date: Mon, 5 Jun 2017 11:34:40 -0500 Subject: Remove deprecated passing of string to :if/:unless (#29357) Other examples were removed in 53ff5fc62f9d11b6f60d371df959137f4bf40728 [ci skip] --- guides/source/active_record_validations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 5313361dfd..6eb5de78be 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -953,7 +953,7 @@ should happen, an `Array` can be used. Moreover, you can apply both `:if` and ```ruby class Computer < ApplicationRecord validates :mouse, presence: true, - if: ["market.retail?", :desktop?], + if: [Proc.new { |c| c.market.retail? }, :desktop?], unless: Proc.new { |c| c.trackpad.present? } end ``` -- cgit v1.2.3 From 2759a53a54fc7d834141adca22f3e76d928a7064 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 6 Jun 2017 17:31:24 +0200 Subject: Tiny documentation fixes [ci skip] --- guides/source/testing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 565f40ed37..7abf3af187 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -602,8 +602,8 @@ Model tests don't have their own superclass like `ActionMailer::TestCase` instea System Testing -------------- -System tests allows test user interactions with your application, running tests -in either a real or a headless browser. System tests uses Capybara as base. +System tests allow you to test user interactions with your application, running tests +in either a real or a headless browser. System tests uses Capybara under the hood. For creating Rails system tests, you use the `test/system` directory in your application. Rails provides a generator to create a system test skeleton for you. @@ -670,7 +670,7 @@ end ``` If your Capybara configuration requires more setup than provided by Rails, this -additional configuration could be added into `application_system_test_case.rb` +additional configuration could be added into the `application_system_test_case.rb` file. Please see [Capybara's documentation](https://github.com/teamcapybara/capybara#setup) -- cgit v1.2.3 From 42198c5591922dd1853a7b7f7cde803ede6a4198 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 6 Jun 2017 17:33:17 +0200 Subject: Remove invalid entry from the guides index page Commit 1a5d9399 removed the "Profiling Rails Applications" guide but the YAML entry for this guide wasn't. [ci skip] --- guides/source/documents.yaml | 5 ----- 1 file changed, 5 deletions(-) (limited to 'guides') diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 2afef57fc2..59205ee465 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -129,11 +129,6 @@ work_in_progress: true url: active_support_instrumentation.html description: This guide explains how to use the instrumentation API inside of Active Support to measure events inside of Rails and other Ruby code. - - - name: Profiling Rails Applications - work_in_progress: true - url: profiling.html - description: This guide explains how to profile your Rails applications to improve performance. - name: Using Rails for API-only Applications url: api_app.html -- cgit v1.2.3 From f59559d70af237f8a52e4ebde34b39d834f2787e Mon Sep 17 00:00:00 2001 From: edwardmp Date: Tue, 6 Jun 2017 23:54:45 +0200 Subject: Update upgrading guide w.r.t. Parameters to use other example method than slice as this has actually been implemented by Parameters --- guides/source/upgrading_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 93864db141..88a7d0a464 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -238,7 +238,7 @@ Run `bin/rails` to see the list of commands available. ### `ActionController::Parameters` No Longer Inherits from `HashWithIndifferentAccess` Calling `params` in your application will now return an object instead of a hash. If your -parameters are already permitted, then you will not need to make any changes. If you are using `slice` +parameters are already permitted, then you will not need to make any changes. If you are using `map` and other methods that depend on being able to read the hash regardless of `permitted?` you will need to upgrade your application to first permit and then convert to a hash. -- cgit v1.2.3 From 75869195725a816822f4403f1eb084162e3eb54b Mon Sep 17 00:00:00 2001 From: Yauheni Dakuka Date: Fri, 9 Jun 2017 14:45:08 +0300 Subject: Fix link in active_record_postgresql.md --- guides/source/active_record_postgresql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md index 6d07291b07..54f6be006e 100644 --- a/guides/source/active_record_postgresql.md +++ b/guides/source/active_record_postgresql.md @@ -84,7 +84,7 @@ Book.where("array_length(ratings, 1) >= 3") ### Hstore * [type definition](http://www.postgresql.org/docs/current/static/hstore.html) -* [functions and operators](http://www.postgresql.org/docs/current/static/hstore.html#AEN167712) +* [functions and operators](http://www.postgresql.org/docs/current/static/hstore.html#AEN179902) NOTE: You need to enable the `hstore` extension to use hstore. -- cgit v1.2.3 From 3910002deaec89e9af73f37a963eef719e7e0f5d Mon Sep 17 00:00:00 2001 From: Yauheni Dakuka Date: Fri, 9 Jun 2017 14:54:28 +0300 Subject: remove the extra comma in association_basics.md --- guides/source/association_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 5c7d1f5365..b0621be8c3 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1831,7 +1831,7 @@ The `limit` method lets you restrict the total number of objects that will be fe class Author < ApplicationRecord has_many :recent_books, -> { order('published_at desc').limit(100) }, - class_name: "Book", + class_name: "Book" end ``` -- cgit v1.2.3 From da783d95711655e4bd29c887b7202a12a0c1d65e Mon Sep 17 00:00:00 2001 From: Yauheni Dakuka Date: Fri, 9 Jun 2017 15:32:42 +0300 Subject: [ci skip] Fix link in active_record_postgresql.md --- guides/source/active_record_postgresql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md index 54f6be006e..041fdacbab 100644 --- a/guides/source/active_record_postgresql.md +++ b/guides/source/active_record_postgresql.md @@ -285,7 +285,7 @@ SELECT n.nspname AS enum_schema, ### UUID * [type definition](http://www.postgresql.org/docs/current/static/datatype-uuid.html) -* [pgcrypto generator function](http://www.postgresql.org/docs/current/static/pgcrypto.html#AEN159361) +* [pgcrypto generator function](http://www.postgresql.org/docs/current/static/pgcrypto.html#AEN182570) * [uuid-ossp generator functions](http://www.postgresql.org/docs/current/static/uuid-ossp.html) NOTE: You need to enable the `pgcrypto` (only PostgreSQL >= 9.4) or `uuid-ossp` -- cgit v1.2.3 From 58de07f70def7b03e7941ecfe993980ca9c4acc7 Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Sat, 10 Jun 2017 11:42:21 +0900 Subject: [ci skip] Add backquote to :counter_cache option --- guides/source/association_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index b0621be8c3..bead931529 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -960,7 +960,7 @@ class Author < ApplicationRecord end ``` -NOTE: You only need to specify the :counter_cache option on the `belongs_to` +NOTE: You only need to specify the `:counter_cache` option on the `belongs_to` side of the association. Counter cache columns are added to the containing model's list of read-only attributes through `attr_readonly`. -- cgit v1.2.3 From 43512df990ff1bba30b4b3cfa427b314a0314623 Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Mon, 29 May 2017 15:44:15 +0300 Subject: Document Module#delegate_missing_to in the guides Added a small section for it in the `Active Support Core Extensions` guide. [ci skip] --- guides/source/active_support_core_extensions.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 67bed4c8da..eb46732127 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -755,6 +755,8 @@ NOTE: Defined in `active_support/core_ext/module/anonymous.rb`. ### Method Delegation +#### `delegate` + The macro `delegate` offers an easy way to forward methods. Let's imagine that users in some application have login information in the `User` model but name and other data in a separate `Profile` model: @@ -837,6 +839,25 @@ In the previous example the macro generates `avatar_size` rather than `size`. NOTE: Defined in `active_support/core_ext/module/delegation.rb` +#### `delegate_missing_to` + +Imagine you would like to delegate everything missing from the `User` object, +to the `Profile` one. The `delegate_missing_to` macro lets you implement this +in a breeze: + +```ruby +class User < ApplicationRecord + has_one :profile + + delegate_missing_to :profile +end +``` + +The target can be anything callable within the object, e.g. instance variables, +methods, constants, etc. Only the public methods of the target are delegated. + +NOTE: Defined in `active_support/core_ext/module/delegation.rb` + ### Redefining Methods There are cases where you need to define a method with `define_method`, but don't know whether a method with that name already exists. If it does, a warning is issued if they are enabled. No big deal, but not clean either. -- cgit v1.2.3 From 76bb3660242a50fab50a34ad745b4fe9c677b83c Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sun, 11 Jun 2017 17:51:08 +0530 Subject: Missing dots [ci skip] (#29414) --- guides/source/active_support_core_extensions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index aa81d1eb6f..23f53ac084 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -856,7 +856,7 @@ end The target can be anything callable within the object, e.g. instance variables, methods, constants, etc. Only the public methods of the target are delegated. -NOTE: Defined in `active_support/core_ext/module/delegation.rb` +NOTE: Defined in `active_support/core_ext/module/delegation.rb`. ### Redefining Methods @@ -864,7 +864,7 @@ There are cases where you need to define a method with `define_method`, but don' The method `redefine_method` prevents such a potential warning, removing the existing method before if needed. -NOTE: Defined in `active_support/core_ext/module/remove_method.rb` +NOTE: Defined in `active_support/core_ext/module/remove_method.rb`. Extensions to `Class` --------------------- @@ -952,7 +952,7 @@ When `:instance_reader` is `false`, the instance predicate returns a `NoMethodEr If you do not want the instance predicate, pass `instance_predicate: false` and it will not be defined. -NOTE: Defined in `active_support/core_ext/class/attribute.rb` +NOTE: Defined in `active_support/core_ext/class/attribute.rb`. #### `cattr_reader`, `cattr_writer`, and `cattr_accessor` @@ -1848,7 +1848,7 @@ as well as adding or subtracting their results from a Time object. For example: (4.months + 5.years).from_now ``` -NOTE: Defined in `active_support/core_ext/numeric/time.rb` +NOTE: Defined in `active_support/core_ext/numeric/time.rb`. ### Formatting -- cgit v1.2.3 From 8426978c54429c28398daca3d14c8b5e52939657 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Mon, 12 Jun 2017 18:40:36 +0530 Subject: Add brakeman to guides/additional resources. Fixes #29383 [ci skip] (#29427) --- guides/source/security.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/security.md b/guides/source/security.md index f69a0c72b0..9b1f28a283 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -1060,6 +1060,7 @@ Additional Resources The security landscape shifts and it is important to keep up to date, because missing a new vulnerability can be catastrophic. You can find additional resources about (Rails) security here: -* Subscribe to the Rails security [mailing list](http://groups.google.com/group/rubyonrails-security) -* [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) +* Subscribe to the Rails security [mailing list.](http://groups.google.com/group/rubyonrails-security) +* [Brakeman - Rails Security Scanner](http://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) -- cgit v1.2.3 From 0cd957ef453d31218eb99c0149589814cc7ef685 Mon Sep 17 00:00:00 2001 From: Dmytro Vasin Date: Tue, 13 Jun 2017 08:37:03 +0300 Subject: Updated `working with javascript` readme to support the behavior of rails-ujs. --- guides/source/working_with_javascript_in_rails.md | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 290f2a509b..35e6aea4cf 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -376,6 +376,35 @@ browser to submit the form via normal means (i.e. non-AJAX submission) will be canceled and the form will not be submitted at all. This is useful for implementing your own AJAX file upload workaround. +### Rails-ujs event handlers + +Rails 5.1 introduced rails-ujs and dropped jQuery as a dependency. +As a result the Unobtrusive JavaScript (UJS) driver has been rewritten to operate without jQuery. +These introductions cause small changes to `custom events` fired during the request: + +NOTE: Signature of calls to UJS’s event handlers have changed. +Unlike the version with jqeury, all custom events return only one parameter: `event`. +In this parameter, there is an additional attribute `details` which contains an array of extra parameters. + +| Event name | Extra parameters (event.detail) | Fired | +|---------------------|---------------------------------|-------------------------------------------------------------| +| `ajax:before` | | Before the whole ajax business. | +| `ajax:beforeSend` | [xhr, options] | Before the request is sent. | +| `ajax:send` | [xhr] | When the request is sent. | +| `ajax:stopped` | | When the request is stopped. | +| `ajax:success` | [response, status, xhr] | After completion, if the response was a success. | +| `ajax:error` | [response, status, xhr] | After completion, if the response was an error. | +| `ajax:complete` | [xhr, status] | After the request has been completed, no matter the outcome.| + +Example usage: + +```html +document.body.addEventListener('ajax:success', function(event) { + var detail = event.detail; + var data = detail[0], status = detail[1], xhr = detail[2]; +}) +``` + Server-Side Concerns -------------------- -- cgit v1.2.3 From 019c7f92f09170f0f87105f544ae4eff49e83de7 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sat, 17 Jun 2017 03:05:37 +0530 Subject: Remove references to deprecared raise_runtime_errors from documentation, which is always enabled now. Ref: https://github.com/rails/sprockets-rails/commit/655b93bffc6f51b96a7cc097f9010942693bfaae and https://github.com/rails/rails/pull/24070 . Fixes #29483 [ci skip] (#29484) --- guides/source/asset_pipeline.md | 14 -------------- guides/source/configuring.md | 2 -- 2 files changed, 16 deletions(-) (limited to 'guides') diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 5d774566dd..a02eebf263 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -572,20 +572,6 @@ would generate this HTML: The `body` param is required by Sprockets. -### Runtime Error Checking - -By default the asset pipeline will check for potential errors in development mode during -runtime. To disable this behavior you can set: - -```ruby -config.assets.raise_runtime_errors = false -``` - -When this option is true, the asset pipeline will check if all the assets loaded -in your application are included in the `config.assets.precompile` list. -If `config.assets.digest` is also true, the asset pipeline will require that -all requests for assets include digests. - ### Raise an Error When an Asset is Not Found If you are using sprockets-rails >= 3.2.0 you can configure what happens diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 1234e1f192..21b3ca0efa 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -157,8 +157,6 @@ defaults to `:debug` for all environments. The available log levels are: `:debug * `config.assets.enabled` a flag that controls whether the asset pipeline is enabled. It is set to `true` by default. -* `config.assets.raise_runtime_errors` Set this flag to `true` to enable additional runtime error checking. Recommended in `config/environments/development.rb` to minimize unexpected behavior when deploying to `production`. - * `config.assets.css_compressor` defines the CSS compressor to use. It is set by default by `sass-rails`. The unique alternative value at the moment is `:yui`, which uses the `yui-compressor` gem. * `config.assets.js_compressor` defines the JavaScript compressor to use. Possible values are `:closure`, `:uglifier` and `:yui` which require the use of the `closure-compiler`, `uglifier` or `yui-compressor` gems respectively. -- cgit v1.2.3 From 133236fa0a99ad18e573e1edc0e48f4f20a32f62 Mon Sep 17 00:00:00 2001 From: utilum Date: Sat, 17 Jun 2017 12:37:42 +0200 Subject: [ci skip] Update fedora SQLite3 package name --- guides/source/development_dependencies_install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/development_dependencies_install.md b/guides/source/development_dependencies_install.md index 7ec038eb4d..c57efd6362 100644 --- a/guides/source/development_dependencies_install.md +++ b/guides/source/development_dependencies_install.md @@ -62,7 +62,7 @@ $ sudo apt-get install sqlite3 libsqlite3-dev If you are on Fedora or CentOS, you're done with ```bash -$ sudo yum install sqlite3 sqlite3-devel +$ sudo yum install libsqlite3x libsqlite3x-devel ``` If you are on Arch Linux, you will need to run: -- cgit v1.2.3 From e062c961e9867b938d4e7a33a25a3de8d0fa67df Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 18 Jun 2017 16:14:00 +0900 Subject: Deprecate an `capify!` method in generators and templates The `capify` command has been removed by Capistrano 3 and became to `cap install`. Therefore, the `capify!` method has no meaning in Capistrano 3. I think that should deprecate. Ref: https://github.com/capistrano/capistrano/commit/492793916acf32ffe1604daec6fd4892c8935018 --- guides/source/generators.md | 8 -------- 1 file changed, 8 deletions(-) (limited to 'guides') diff --git a/guides/source/generators.md b/guides/source/generators.md index d4ed2355d4..be1be75e7a 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -689,14 +689,6 @@ Available options are: * `:env` - Specifies the environment in which to run this rake task. * `:sudo` - Whether or not to run this task using `sudo`. Defaults to `false`. -### `capify!` - -Runs the `capify` command from Capistrano at the root of the application which generates Capistrano configuration. - -```ruby -capify! -``` - ### `route` Adds text to the `config/routes.rb` file: -- cgit v1.2.3 From f006edeb940e8636bab012f098f0aa125c72c4a6 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Tue, 20 Jun 2017 20:50:36 +0530 Subject: [ci skip] Fixed the attribute name for event.detail --- guides/source/working_with_javascript_in_rails.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 35e6aea4cf..ed27752a06 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -382,9 +382,9 @@ Rails 5.1 introduced rails-ujs and dropped jQuery as a dependency. As a result the Unobtrusive JavaScript (UJS) driver has been rewritten to operate without jQuery. These introductions cause small changes to `custom events` fired during the request: -NOTE: Signature of calls to UJS’s event handlers have changed. -Unlike the version with jqeury, all custom events return only one parameter: `event`. -In this parameter, there is an additional attribute `details` which contains an array of extra parameters. +NOTE: Signature of calls to UJS’s event handlers has changed. +Unlike the version with jQuery, all custom events return only one parameter: `event`. +In this parameter, there is an additional attribute `detail` which contains an array of extra parameters. | Event name | Extra parameters (event.detail) | Fired | |---------------------|---------------------------------|-------------------------------------------------------------| -- cgit v1.2.3 From 0f89fdcf254d972c5765bf3c1b0c8513ef9a9498 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 21 Jun 2017 01:38:43 +0900 Subject: Shrink image files in the guides using ImageOptim --- guides/assets/images/belongs_to.png | Bin 25803 -> 22147 bytes .../getting_started/article_with_comments.png | Bin 22560 -> 13884 bytes guides/assets/images/getting_started/challenge.png | Bin 21690 -> 20347 bytes .../images/getting_started/confirm_dialog.png | Bin 18809 -> 17507 bytes .../forbidden_attributes_for_new_article.png | Bin 10783 -> 9851 bytes .../images/getting_started/form_with_errors.png | Bin 12447 -> 11665 bytes .../index_action_with_edit_link.png | Bin 10209 -> 9703 bytes .../assets/images/getting_started/new_article.png | Bin 3579 -> 3193 bytes .../images/getting_started/rails_welcome.png | Bin 1053549 -> 732190 bytes .../routing_error_no_controller.png | Bin 4186 -> 3869 bytes .../getting_started/show_action_for_articles.png | Bin 2965 -> 2901 bytes .../template_is_missing_articles_new.png | Bin 587962 -> 472167 bytes .../unknown_action_create_for_articles.png | Bin 5327 -> 4808 bytes .../unknown_action_new_for_articles.png | Bin 5481 -> 4933 bytes guides/assets/images/habtm.png | Bin 49332 -> 47284 bytes guides/assets/images/has_many.png | Bin 28919 -> 24300 bytes guides/assets/images/has_many_through.png | Bin 79428 -> 78099 bytes guides/assets/images/has_one.png | Bin 29072 -> 27547 bytes guides/assets/images/has_one_through.png | Bin 72434 -> 70130 bytes guides/assets/images/header_backdrop.png | Bin 224 -> 206 bytes guides/assets/images/i18n/demo_html_safe.png | Bin 10073 -> 9860 bytes .../assets/images/i18n/demo_localized_pirate.png | Bin 11485 -> 11214 bytes guides/assets/images/i18n/demo_translated_en.png | Bin 9325 -> 9069 bytes .../assets/images/i18n/demo_translated_pirate.png | Bin 10202 -> 9974 bytes .../images/i18n/demo_translation_missing.png | Bin 10260 -> 9984 bytes guides/assets/images/i18n/demo_untranslated.png | Bin 9224 -> 8985 bytes guides/assets/images/icons/callouts/14.png | Bin 246 -> 190 bytes guides/assets/images/icons/example.png | Bin 2078 -> 2052 bytes guides/assets/images/icons/home.png | Bin 1163 -> 1134 bytes guides/assets/images/icons/important.png | Bin 2451 -> 2426 bytes guides/assets/images/icons/next.png | Bin 1146 -> 1111 bytes guides/assets/images/icons/note.png | Bin 2155 -> 2096 bytes guides/assets/images/icons/prev.png | Bin 1126 -> 1093 bytes guides/assets/images/icons/tip.png | Bin 2248 -> 2170 bytes guides/assets/images/icons/up.png | Bin 1133 -> 1106 bytes guides/assets/images/polymorphic.png | Bin 66415 -> 65417 bytes guides/assets/images/rails4_features.png | Bin 67766 -> 65840 bytes guides/assets/images/session_fixation.png | Bin 38451 -> 38296 bytes guides/assets/images/tab_yellow.png | Bin 1441 -> 1395 bytes 39 files changed, 0 insertions(+), 0 deletions(-) (limited to 'guides') diff --git a/guides/assets/images/belongs_to.png b/guides/assets/images/belongs_to.png index 077d237e4e..1a9926e578 100644 Binary files a/guides/assets/images/belongs_to.png and b/guides/assets/images/belongs_to.png differ diff --git a/guides/assets/images/getting_started/article_with_comments.png b/guides/assets/images/getting_started/article_with_comments.png index c489e4c00e..3f16f3b280 100644 Binary files a/guides/assets/images/getting_started/article_with_comments.png and b/guides/assets/images/getting_started/article_with_comments.png differ diff --git a/guides/assets/images/getting_started/challenge.png b/guides/assets/images/getting_started/challenge.png index 5b88a842b2..d05ef31bbe 100644 Binary files a/guides/assets/images/getting_started/challenge.png and b/guides/assets/images/getting_started/challenge.png differ diff --git a/guides/assets/images/getting_started/confirm_dialog.png b/guides/assets/images/getting_started/confirm_dialog.png index 9755f581a6..ce65734e6c 100644 Binary files a/guides/assets/images/getting_started/confirm_dialog.png and b/guides/assets/images/getting_started/confirm_dialog.png differ diff --git a/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png b/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png index 9f32c68472..50b178808e 100644 Binary files a/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png and b/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png differ diff --git a/guides/assets/images/getting_started/form_with_errors.png b/guides/assets/images/getting_started/form_with_errors.png index 98bff37d4a..6eefd2885a 100644 Binary files a/guides/assets/images/getting_started/form_with_errors.png and b/guides/assets/images/getting_started/form_with_errors.png differ diff --git a/guides/assets/images/getting_started/index_action_with_edit_link.png b/guides/assets/images/getting_started/index_action_with_edit_link.png index 0566a3ffde..a2a087a598 100644 Binary files a/guides/assets/images/getting_started/index_action_with_edit_link.png and b/guides/assets/images/getting_started/index_action_with_edit_link.png differ diff --git a/guides/assets/images/getting_started/new_article.png b/guides/assets/images/getting_started/new_article.png index bd3ae4fa67..6edcc161b6 100644 Binary files a/guides/assets/images/getting_started/new_article.png and b/guides/assets/images/getting_started/new_article.png differ diff --git a/guides/assets/images/getting_started/rails_welcome.png b/guides/assets/images/getting_started/rails_welcome.png index baccb11322..44f89ec8de 100644 Binary files a/guides/assets/images/getting_started/rails_welcome.png and b/guides/assets/images/getting_started/rails_welcome.png differ diff --git a/guides/assets/images/getting_started/routing_error_no_controller.png b/guides/assets/images/getting_started/routing_error_no_controller.png index ed62862291..52150f0426 100644 Binary files a/guides/assets/images/getting_started/routing_error_no_controller.png and b/guides/assets/images/getting_started/routing_error_no_controller.png differ diff --git a/guides/assets/images/getting_started/show_action_for_articles.png b/guides/assets/images/getting_started/show_action_for_articles.png index 4dad704f89..68837131f7 100644 Binary files a/guides/assets/images/getting_started/show_action_for_articles.png and b/guides/assets/images/getting_started/show_action_for_articles.png differ diff --git a/guides/assets/images/getting_started/template_is_missing_articles_new.png b/guides/assets/images/getting_started/template_is_missing_articles_new.png index f4f054f3c6..a1603f5d28 100644 Binary files a/guides/assets/images/getting_started/template_is_missing_articles_new.png and b/guides/assets/images/getting_started/template_is_missing_articles_new.png differ diff --git a/guides/assets/images/getting_started/unknown_action_create_for_articles.png b/guides/assets/images/getting_started/unknown_action_create_for_articles.png index fd20cd53dc..ec4758e085 100644 Binary files a/guides/assets/images/getting_started/unknown_action_create_for_articles.png and b/guides/assets/images/getting_started/unknown_action_create_for_articles.png differ diff --git a/guides/assets/images/getting_started/unknown_action_new_for_articles.png b/guides/assets/images/getting_started/unknown_action_new_for_articles.png index e948a51e4a..f7e7464d61 100644 Binary files a/guides/assets/images/getting_started/unknown_action_new_for_articles.png and b/guides/assets/images/getting_started/unknown_action_new_for_articles.png differ diff --git a/guides/assets/images/habtm.png b/guides/assets/images/habtm.png index b062bc73fe..41013b743d 100644 Binary files a/guides/assets/images/habtm.png and b/guides/assets/images/habtm.png differ diff --git a/guides/assets/images/has_many.png b/guides/assets/images/has_many.png index 79da2613d7..0d67bea38b 100644 Binary files a/guides/assets/images/has_many.png and b/guides/assets/images/has_many.png differ diff --git a/guides/assets/images/has_many_through.png b/guides/assets/images/has_many_through.png index 858c898dc1..b4da60e1fb 100644 Binary files a/guides/assets/images/has_many_through.png and b/guides/assets/images/has_many_through.png differ diff --git a/guides/assets/images/has_one.png b/guides/assets/images/has_one.png index 93faa05b07..c70763856a 100644 Binary files a/guides/assets/images/has_one.png and b/guides/assets/images/has_one.png differ diff --git a/guides/assets/images/has_one_through.png b/guides/assets/images/has_one_through.png index 07dac1a27d..888a02b775 100644 Binary files a/guides/assets/images/has_one_through.png and b/guides/assets/images/has_one_through.png differ diff --git a/guides/assets/images/header_backdrop.png b/guides/assets/images/header_backdrop.png index 72b030478f..81f4d91774 100644 Binary files a/guides/assets/images/header_backdrop.png and b/guides/assets/images/header_backdrop.png differ diff --git a/guides/assets/images/i18n/demo_html_safe.png b/guides/assets/images/i18n/demo_html_safe.png index 9afa8ebec1..be75d4830e 100644 Binary files a/guides/assets/images/i18n/demo_html_safe.png and b/guides/assets/images/i18n/demo_html_safe.png differ diff --git a/guides/assets/images/i18n/demo_localized_pirate.png b/guides/assets/images/i18n/demo_localized_pirate.png index bf8d0b558c..528cc27900 100644 Binary files a/guides/assets/images/i18n/demo_localized_pirate.png and b/guides/assets/images/i18n/demo_localized_pirate.png differ diff --git a/guides/assets/images/i18n/demo_translated_en.png b/guides/assets/images/i18n/demo_translated_en.png index e887bfa306..bbb5e93c3a 100644 Binary files a/guides/assets/images/i18n/demo_translated_en.png and b/guides/assets/images/i18n/demo_translated_en.png differ diff --git a/guides/assets/images/i18n/demo_translated_pirate.png b/guides/assets/images/i18n/demo_translated_pirate.png index aa5618a865..305fa93a14 100644 Binary files a/guides/assets/images/i18n/demo_translated_pirate.png and b/guides/assets/images/i18n/demo_translated_pirate.png differ diff --git a/guides/assets/images/i18n/demo_translation_missing.png b/guides/assets/images/i18n/demo_translation_missing.png index 867aa7c42d..e9833ba307 100644 Binary files a/guides/assets/images/i18n/demo_translation_missing.png and b/guides/assets/images/i18n/demo_translation_missing.png differ diff --git a/guides/assets/images/i18n/demo_untranslated.png b/guides/assets/images/i18n/demo_untranslated.png index 2ea6404822..2653abc491 100644 Binary files a/guides/assets/images/i18n/demo_untranslated.png and b/guides/assets/images/i18n/demo_untranslated.png differ diff --git a/guides/assets/images/icons/callouts/14.png b/guides/assets/images/icons/callouts/14.png index 4274e6580a..dbde9ca749 100644 Binary files a/guides/assets/images/icons/callouts/14.png and b/guides/assets/images/icons/callouts/14.png differ diff --git a/guides/assets/images/icons/example.png b/guides/assets/images/icons/example.png index de23c0aa87..a0e855befa 100644 Binary files a/guides/assets/images/icons/example.png and b/guides/assets/images/icons/example.png differ diff --git a/guides/assets/images/icons/home.png b/guides/assets/images/icons/home.png index 24149d6e78..e70e164522 100644 Binary files a/guides/assets/images/icons/home.png and b/guides/assets/images/icons/home.png differ diff --git a/guides/assets/images/icons/important.png b/guides/assets/images/icons/important.png index dafcf0f59e..bab53bf3aa 100644 Binary files a/guides/assets/images/icons/important.png and b/guides/assets/images/icons/important.png differ diff --git a/guides/assets/images/icons/next.png b/guides/assets/images/icons/next.png index 355b329f5a..a158832725 100644 Binary files a/guides/assets/images/icons/next.png and b/guides/assets/images/icons/next.png differ diff --git a/guides/assets/images/icons/note.png b/guides/assets/images/icons/note.png index 08d35a6f5c..62eec7845f 100644 Binary files a/guides/assets/images/icons/note.png and b/guides/assets/images/icons/note.png differ diff --git a/guides/assets/images/icons/prev.png b/guides/assets/images/icons/prev.png index ea564c865e..8a96960422 100644 Binary files a/guides/assets/images/icons/prev.png and b/guides/assets/images/icons/prev.png differ diff --git a/guides/assets/images/icons/tip.png b/guides/assets/images/icons/tip.png index d834e6d1bb..a5316d318f 100644 Binary files a/guides/assets/images/icons/tip.png and b/guides/assets/images/icons/tip.png differ diff --git a/guides/assets/images/icons/up.png b/guides/assets/images/icons/up.png index 379f0045af..6cac818170 100644 Binary files a/guides/assets/images/icons/up.png and b/guides/assets/images/icons/up.png differ diff --git a/guides/assets/images/polymorphic.png b/guides/assets/images/polymorphic.png index a3cbc4502a..e0a7f6d64a 100644 Binary files a/guides/assets/images/polymorphic.png and b/guides/assets/images/polymorphic.png differ diff --git a/guides/assets/images/rails4_features.png b/guides/assets/images/rails4_features.png index b3bd5ef69e..ac73f05cf7 100644 Binary files a/guides/assets/images/rails4_features.png and b/guides/assets/images/rails4_features.png differ diff --git a/guides/assets/images/session_fixation.png b/guides/assets/images/session_fixation.png index ac3ab01614..e009484f09 100644 Binary files a/guides/assets/images/session_fixation.png and b/guides/assets/images/session_fixation.png differ diff --git a/guides/assets/images/tab_yellow.png b/guides/assets/images/tab_yellow.png index 3ab1c56c4d..053c807d28 100644 Binary files a/guides/assets/images/tab_yellow.png and b/guides/assets/images/tab_yellow.png differ -- cgit v1.2.3 From 2dafc4be2285bc2cb32983be6f16296319b40e25 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 22 Jun 2017 08:08:45 +0900 Subject: Do not use private API in bug report templates `ActiveRecord::Migrator` is private API. https://github.com/rails/rails/blob/bb9d6eb094f29bb94ef1f26aa44f145f17b973fe/activerecord/lib/active_record/migration.rb#L977 Therefore, it is not good to use it in bug report templates. Instead, should use the public API `ActiveRecord::Migration#migrate`. --- guides/bug_report_templates/active_record_migrations_gem.rb | 6 ++---- guides/bug_report_templates/active_record_migrations_master.rb | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'guides') diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index 0c398e334a..00ba3c1cd6 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -48,16 +48,14 @@ end class BugTest < Minitest::Test def test_migration_up - migrator = ActiveRecord::Migrator.new(:up, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:up) Payment.reset_column_information assert_equal "decimal(10,2)", Payment.columns.last.sql_type end def test_migration_down - migrator = ActiveRecord::Migrator.new(:down, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:down) Payment.reset_column_information assert_equal "decimal(10,0)", Payment.columns.last.sql_type diff --git a/guides/bug_report_templates/active_record_migrations_master.rb b/guides/bug_report_templates/active_record_migrations_master.rb index 84a4b71909..52c9028b0f 100644 --- a/guides/bug_report_templates/active_record_migrations_master.rb +++ b/guides/bug_report_templates/active_record_migrations_master.rb @@ -48,16 +48,14 @@ end class BugTest < Minitest::Test def test_migration_up - migrator = ActiveRecord::Migrator.new(:up, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:up) Payment.reset_column_information assert_equal "decimal(10,2)", Payment.columns.last.sql_type end def test_migration_down - migrator = ActiveRecord::Migrator.new(:down, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:down) Payment.reset_column_information assert_equal "decimal(10,0)", Payment.columns.last.sql_type -- cgit v1.2.3 From 3b308f3321bada45eaad78ee14219dd5d98106fb Mon Sep 17 00:00:00 2001 From: Abraham Chan Date: Thu, 22 Jun 2017 14:10:17 +1000 Subject: Fix hash conditions documentation [ci skip] --- guides/source/active_record_querying.md | 2 -- 1 file changed, 2 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 3676462788..215142223d 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -513,8 +513,6 @@ Article.where(author: author) Author.joins(:articles).where(articles: { author: author }) ``` -NOTE: The values cannot be symbols. For example, you cannot do `Client.where(status: :active)`. - #### Range Conditions ```ruby -- cgit v1.2.3 From 4d433f8d21972d738f625bb4e41065e179ea01a8 Mon Sep 17 00:00:00 2001 From: Yong Bakos Date: Fri, 23 Jun 2017 22:44:55 -0700 Subject: Guides: Clarify partial local variable naming. Clarify the partial local variable name as being the same as the name of the partial, minus the _leading_ underscore. --- guides/source/layouts_and_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index caa3d21d23..c96cf61761 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -1171,7 +1171,7 @@ To pass a local variable to a partial in only specific cases use the `local_assi This way it is possible to use the partial without the need to declare all local variables. -Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the `:object` option: +Every partial also has a local variable with the same name as the partial (minus the leading underscore). You can pass an object in to this local variable via the `:object` option: ```erb <%= render partial: "customer", object: @new_customer %> -- cgit v1.2.3 From dafe3f82cf3120b1e61ffdaa3c20e989c87c851f Mon Sep 17 00:00:00 2001 From: Yauheni Dakuka Date: Mon, 26 Jun 2017 22:17:16 +0300 Subject: Update security.md --- 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 9b1f28a283..297680b176 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -1061,6 +1061,6 @@ Additional Resources The security landscape shifts and it is important to keep up to date, because missing a new vulnerability can be catastrophic. You can find additional resources about (Rails) security here: * Subscribe to the Rails security [mailing list.](http://groups.google.com/group/rubyonrails-security) -* [Brakeman - Rails Security Scanner](http://brakemanscanner.org/)- To perform static security analysis for Rails applications. +* [Brakeman - Rails Security Scanner](http://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) -- cgit v1.2.3 From 6fbd405a2eb585591bb57de5adae71f890a24af3 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 22 Jun 2017 22:17:18 +0900 Subject: Clear screenshots files in `tmp:clear` task If system test fails, it creates screenshot under `tmp/screenshots`. https://github.com/rails/rails/blob/34fe2a4fc778d18b7fe6bdf3629c1481bee789b9/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L45 But currently, screenshot files is not cleared by `tmp:clear` task. This patch make clears screenshot files with `tmp:clear` task as well as other tmp files. --- guides/source/command_line.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'guides') diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 3360496c08..9fddbf76b6 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -262,12 +262,12 @@ $ bin/rails db:migrate == CreateHighScores: migrated (0.0019s) ====================================== ``` -INFO: Let's talk about unit tests. Unit tests are code that tests and makes assertions -about code. In unit testing, we take a little part of code, say a method of a model, -and test its inputs and outputs. Unit tests are your friend. The sooner you make -peace with the fact that your quality of life will drastically increase when you unit -test your code, the better. Seriously. Please visit -[the testing guide](http://guides.rubyonrails.org/testing.html) for an in-depth +INFO: Let's talk about unit tests. Unit tests are code that tests and makes assertions +about code. In unit testing, we take a little part of code, say a method of a model, +and test its inputs and outputs. Unit tests are your friend. The sooner you make +peace with the fact that your quality of life will drastically increase when you unit +test your code, the better. Seriously. Please visit +[the testing guide](http://guides.rubyonrails.org/testing.html) for an in-depth look at unit testing. Let's see the interface Rails created for us. @@ -533,7 +533,8 @@ The `tmp:` namespaced tasks will help you clear and create the `Rails.root/tmp` * `rails tmp:cache:clear` clears `tmp/cache`. * `rails tmp:sockets:clear` clears `tmp/sockets`. -* `rails tmp:clear` clears all cache and sockets files. +* `rails tmp:screenshots:clear` clears `tmp/screenshots`. +* `rails tmp:clear` clears all cache, sockets and screenshot files. * `rails tmp:create` creates tmp directories for cache, sockets and pids. ### Miscellaneous -- cgit v1.2.3 From 927e98621983d33795a99434492c3bb8ee7cd764 Mon Sep 17 00:00:00 2001 From: Marc Rendl Ignacio Date: Tue, 27 Jun 2017 17:10:26 +0800 Subject: Document ActiveRecord's PostgreSQL-specific support for JSONB datatype in RailsGuides [ci skip] --- guides/source/active_record_postgresql.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md index 041fdacbab..8543fcd20f 100644 --- a/guides/source/active_record_postgresql.md +++ b/guides/source/active_record_postgresql.md @@ -114,16 +114,21 @@ Profile.where("settings->'color' = ?", "yellow") # => #"yellow", "resolution"=>"1280x1024"}>]> ``` -### JSON +### JSON and JSONB * [type definition](http://www.postgresql.org/docs/current/static/datatype-json.html) * [functions and operators](http://www.postgresql.org/docs/current/static/functions-json.html) ```ruby # db/migrate/20131220144913_create_events.rb +# ... for json datatype: create_table :events do |t| t.json 'payload' end +# ... or for jsonb datatype: +create_table :events do |t| + t.jsonb 'payload' +end # app/models/event.rb class Event < ApplicationRecord -- cgit v1.2.3 From fd54d8449af7d1a3bada23f5475bdaa723304cd4 Mon Sep 17 00:00:00 2001 From: James Bush Date: Wed, 28 Jun 2017 12:54:18 -0400 Subject: Fix grammar for documentation of rails/command.rb [ci skip] --- 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 3ea156c6fe..86aea2c24d 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -155,7 +155,7 @@ defined here to find the matching command. ### `rails/command.rb` When one types a Rails command, `invoke` tries to lookup a command for the given -namespace and executing the command if found. +namespace and executes the command if found. If Rails doesn't recognize the command, it hands the reins over to Rake to run a task of the same name. -- cgit v1.2.3 From 1f48de101bce1b63e0b250c371a17fb4e851e457 Mon Sep 17 00:00:00 2001 From: Jorge Dias Date: Thu, 29 Jun 2017 00:16:41 +0200 Subject: Specify correct extension for text layouts When using render plain the extension for the layout needs to be .text.erb instead of .txt.erb --- guides/source/layouts_and_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index c96cf61761..57e603ec0d 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -221,7 +221,7 @@ service requests that are expecting something other than proper HTML. NOTE: By default, if you use the `:plain` option, the text is rendered without using the current layout. If you want Rails to put the text into the current -layout, you need to add the `layout: true` option and use the `.txt.erb` +layout, you need to add the `layout: true` option and use the `.text.erb` extension for the layout file. #### Rendering HTML -- cgit v1.2.3 From 05602968b9808a0b4f9dac5094168c102a5782ef Mon Sep 17 00:00:00 2001 From: Sai Prashanth Date: Fri, 30 Jun 2017 16:27:00 +0530 Subject: [ci skip] run migration before looking at schema --- guides/source/getting_started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 49c691c841..2ed1883ede 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1546,8 +1546,8 @@ You'll learn a little about associations in the next section of this guide. The (`:references`) keyword used in the bash command is a special data type for models. It creates a new column on your database table with the provided model name appended with an `_id` -that can hold integer values. You can get a better understanding after analyzing the -`db/schema.rb` file below. +that can hold integer values. To get a better understanding, analyze the +`db/schema.rb` file after running the migration. In addition to the model, Rails has also made a migration to create the corresponding database table: -- cgit v1.2.3 From cfade1ec7ee7b5b51f3c1578e3474f9c156f2971 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Thu, 22 Jun 2017 22:59:18 -0400 Subject: Enforce frozen string in Rubocop --- guides/Rakefile | 1 + guides/bug_report_templates/action_controller_gem.rb | 1 + guides/bug_report_templates/action_controller_master.rb | 1 + guides/bug_report_templates/active_job_gem.rb | 1 + guides/bug_report_templates/active_job_master.rb | 1 + guides/bug_report_templates/active_record_gem.rb | 1 + guides/bug_report_templates/active_record_master.rb | 1 + guides/bug_report_templates/active_record_migrations_gem.rb | 1 + guides/bug_report_templates/active_record_migrations_master.rb | 1 + guides/bug_report_templates/benchmark.rb | 1 + guides/bug_report_templates/generic_gem.rb | 1 + guides/bug_report_templates/generic_master.rb | 1 + guides/rails_guides.rb | 1 + guides/rails_guides/generator.rb | 1 + guides/rails_guides/helpers.rb | 1 + guides/rails_guides/indexer.rb | 1 + guides/rails_guides/kindle.rb | 1 + guides/rails_guides/levenshtein.rb | 1 + guides/rails_guides/markdown.rb | 1 + guides/rails_guides/markdown/renderer.rb | 1 + guides/w3c_validator.rb | 1 + 21 files changed, 21 insertions(+) (limited to 'guides') diff --git a/guides/Rakefile b/guides/Rakefile index 3a6f10040f..653255a6b5 100644 --- a/guides/Rakefile +++ b/guides/Rakefile @@ -1,3 +1,4 @@ +# frozen_string_literal: true namespace :guides do desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"' task generate: "generate:html" diff --git a/guides/bug_report_templates/action_controller_gem.rb b/guides/bug_report_templates/action_controller_gem.rb index 8b7aa893fd..49fe6c61c2 100644 --- a/guides/bug_report_templates/action_controller_gem.rb +++ b/guides/bug_report_templates/action_controller_gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/action_controller_master.rb b/guides/bug_report_templates/action_controller_master.rb index 3dd66c95ec..1aca491f03 100644 --- a/guides/bug_report_templates/action_controller_master.rb +++ b/guides/bug_report_templates/action_controller_master.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_job_gem.rb b/guides/bug_report_templates/active_job_gem.rb index 252b270a0c..7184e47df7 100644 --- a/guides/bug_report_templates/active_job_gem.rb +++ b/guides/bug_report_templates/active_job_gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_job_master.rb b/guides/bug_report_templates/active_job_master.rb index 7591470440..75b15958dc 100644 --- a/guides/bug_report_templates/active_job_master.rb +++ b/guides/bug_report_templates/active_job_master.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb index 61d4e8d395..e5d1ff24f6 100644 --- a/guides/bug_report_templates/active_record_gem.rb +++ b/guides/bug_report_templates/active_record_gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_master.rb b/guides/bug_report_templates/active_record_master.rb index 8bbc1ef19e..66f923e52a 100644 --- a/guides/bug_report_templates/active_record_master.rb +++ b/guides/bug_report_templates/active_record_master.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index 00ba3c1cd6..2d7b3ef05e 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_migrations_master.rb b/guides/bug_report_templates/active_record_migrations_master.rb index 52c9028b0f..363360828d 100644 --- a/guides/bug_report_templates/active_record_migrations_master.rb +++ b/guides/bug_report_templates/active_record_migrations_master.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/benchmark.rb b/guides/bug_report_templates/benchmark.rb index 54433b34dd..91466f56e0 100644 --- a/guides/bug_report_templates/benchmark.rb +++ b/guides/bug_report_templates/benchmark.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/generic_gem.rb b/guides/bug_report_templates/generic_gem.rb index 4dcd04ea27..d22af83e25 100644 --- a/guides/bug_report_templates/generic_gem.rb +++ b/guides/bug_report_templates/generic_gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/generic_master.rb b/guides/bug_report_templates/generic_master.rb index ed45726e92..168b639843 100644 --- a/guides/bug_report_templates/generic_master.rb +++ b/guides/bug_report_templates/generic_master.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/rails_guides.rb b/guides/rails_guides.rb index 0f611c8f2b..52e66d5324 100644 --- a/guides/rails_guides.rb +++ b/guides/rails_guides.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true $:.unshift __dir__ as_lib = File.expand_path("../activesupport/lib", __dir__) diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index 35f014747c..04ab89093a 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "set" require "fileutils" diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb index 520aa7f7cc..f68e1f597f 100644 --- a/guides/rails_guides/helpers.rb +++ b/guides/rails_guides/helpers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "yaml" module RailsGuides diff --git a/guides/rails_guides/indexer.rb b/guides/rails_guides/indexer.rb index c58b6b85a2..63dbfd5e2c 100644 --- a/guides/rails_guides/indexer.rb +++ b/guides/rails_guides/indexer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "active_support/core_ext/object/blank" require "active_support/core_ext/string/inflections" diff --git a/guides/rails_guides/kindle.rb b/guides/rails_guides/kindle.rb index 9536d0bd3b..87a369a15a 100644 --- a/guides/rails_guides/kindle.rb +++ b/guides/rails_guides/kindle.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "kindlerb" require "nokogiri" diff --git a/guides/rails_guides/levenshtein.rb b/guides/rails_guides/levenshtein.rb index 40c6a5c372..90bb40dfc2 100644 --- a/guides/rails_guides/levenshtein.rb +++ b/guides/rails_guides/levenshtein.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module RailsGuides module Levenshtein # This code is based directly on the Text gem implementation. diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb index 02d58601c4..cad66b5d6d 100644 --- a/guides/rails_guides/markdown.rb +++ b/guides/rails_guides/markdown.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "redcarpet" require "nokogiri" require "rails_guides/markdown/renderer" diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb index 7ac3d417a4..583a8d348f 100644 --- a/guides/rails_guides/markdown/renderer.rb +++ b/guides/rails_guides/markdown/renderer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module RailsGuides class Markdown class Renderer < Redcarpet::Render::HTML diff --git a/guides/w3c_validator.rb b/guides/w3c_validator.rb index 4671e040ca..a97599ad3b 100644 --- a/guides/w3c_validator.rb +++ b/guides/w3c_validator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # --------------------------------------------------------------------------- # # This script validates the generated guides against the W3C Validator. -- cgit v1.2.3 From 87b3e226d65ac1ed371620bfdcd2f950c87cfece Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sun, 2 Jul 2017 02:15:17 +0930 Subject: Revert "Merge pull request #29540 from kirs/rubocop-frozen-string" This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa. --- guides/Rakefile | 1 - guides/bug_report_templates/action_controller_gem.rb | 1 - guides/bug_report_templates/action_controller_master.rb | 1 - guides/bug_report_templates/active_job_gem.rb | 1 - guides/bug_report_templates/active_job_master.rb | 1 - guides/bug_report_templates/active_record_gem.rb | 1 - guides/bug_report_templates/active_record_master.rb | 1 - guides/bug_report_templates/active_record_migrations_gem.rb | 1 - guides/bug_report_templates/active_record_migrations_master.rb | 1 - guides/bug_report_templates/benchmark.rb | 1 - guides/bug_report_templates/generic_gem.rb | 1 - guides/bug_report_templates/generic_master.rb | 1 - guides/rails_guides.rb | 1 - guides/rails_guides/generator.rb | 1 - guides/rails_guides/helpers.rb | 1 - guides/rails_guides/indexer.rb | 1 - guides/rails_guides/kindle.rb | 1 - guides/rails_guides/levenshtein.rb | 1 - guides/rails_guides/markdown.rb | 1 - guides/rails_guides/markdown/renderer.rb | 1 - guides/w3c_validator.rb | 1 - 21 files changed, 21 deletions(-) (limited to 'guides') diff --git a/guides/Rakefile b/guides/Rakefile index 653255a6b5..3a6f10040f 100644 --- a/guides/Rakefile +++ b/guides/Rakefile @@ -1,4 +1,3 @@ -# frozen_string_literal: true namespace :guides do desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"' task generate: "generate:html" diff --git a/guides/bug_report_templates/action_controller_gem.rb b/guides/bug_report_templates/action_controller_gem.rb index 49fe6c61c2..8b7aa893fd 100644 --- a/guides/bug_report_templates/action_controller_gem.rb +++ b/guides/bug_report_templates/action_controller_gem.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/action_controller_master.rb b/guides/bug_report_templates/action_controller_master.rb index 1aca491f03..3dd66c95ec 100644 --- a/guides/bug_report_templates/action_controller_master.rb +++ b/guides/bug_report_templates/action_controller_master.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_job_gem.rb b/guides/bug_report_templates/active_job_gem.rb index 7184e47df7..252b270a0c 100644 --- a/guides/bug_report_templates/active_job_gem.rb +++ b/guides/bug_report_templates/active_job_gem.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_job_master.rb b/guides/bug_report_templates/active_job_master.rb index 75b15958dc..7591470440 100644 --- a/guides/bug_report_templates/active_job_master.rb +++ b/guides/bug_report_templates/active_job_master.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb index e5d1ff24f6..61d4e8d395 100644 --- a/guides/bug_report_templates/active_record_gem.rb +++ b/guides/bug_report_templates/active_record_gem.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_master.rb b/guides/bug_report_templates/active_record_master.rb index 66f923e52a..8bbc1ef19e 100644 --- a/guides/bug_report_templates/active_record_master.rb +++ b/guides/bug_report_templates/active_record_master.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index 2d7b3ef05e..00ba3c1cd6 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/active_record_migrations_master.rb b/guides/bug_report_templates/active_record_migrations_master.rb index 363360828d..52c9028b0f 100644 --- a/guides/bug_report_templates/active_record_migrations_master.rb +++ b/guides/bug_report_templates/active_record_migrations_master.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/benchmark.rb b/guides/bug_report_templates/benchmark.rb index 91466f56e0..54433b34dd 100644 --- a/guides/bug_report_templates/benchmark.rb +++ b/guides/bug_report_templates/benchmark.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/generic_gem.rb b/guides/bug_report_templates/generic_gem.rb index d22af83e25..4dcd04ea27 100644 --- a/guides/bug_report_templates/generic_gem.rb +++ b/guides/bug_report_templates/generic_gem.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/bug_report_templates/generic_master.rb b/guides/bug_report_templates/generic_master.rb index 168b639843..ed45726e92 100644 --- a/guides/bug_report_templates/generic_master.rb +++ b/guides/bug_report_templates/generic_master.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true begin require "bundler/inline" rescue LoadError => e diff --git a/guides/rails_guides.rb b/guides/rails_guides.rb index 52e66d5324..0f611c8f2b 100644 --- a/guides/rails_guides.rb +++ b/guides/rails_guides.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true $:.unshift __dir__ as_lib = File.expand_path("../activesupport/lib", __dir__) diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index 04ab89093a..35f014747c 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true require "set" require "fileutils" diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb index f68e1f597f..520aa7f7cc 100644 --- a/guides/rails_guides/helpers.rb +++ b/guides/rails_guides/helpers.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true require "yaml" module RailsGuides diff --git a/guides/rails_guides/indexer.rb b/guides/rails_guides/indexer.rb index 63dbfd5e2c..c58b6b85a2 100644 --- a/guides/rails_guides/indexer.rb +++ b/guides/rails_guides/indexer.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true require "active_support/core_ext/object/blank" require "active_support/core_ext/string/inflections" diff --git a/guides/rails_guides/kindle.rb b/guides/rails_guides/kindle.rb index 87a369a15a..9536d0bd3b 100644 --- a/guides/rails_guides/kindle.rb +++ b/guides/rails_guides/kindle.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true require "kindlerb" require "nokogiri" diff --git a/guides/rails_guides/levenshtein.rb b/guides/rails_guides/levenshtein.rb index 90bb40dfc2..40c6a5c372 100644 --- a/guides/rails_guides/levenshtein.rb +++ b/guides/rails_guides/levenshtein.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true module RailsGuides module Levenshtein # This code is based directly on the Text gem implementation. diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb index cad66b5d6d..02d58601c4 100644 --- a/guides/rails_guides/markdown.rb +++ b/guides/rails_guides/markdown.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true require "redcarpet" require "nokogiri" require "rails_guides/markdown/renderer" diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb index 583a8d348f..7ac3d417a4 100644 --- a/guides/rails_guides/markdown/renderer.rb +++ b/guides/rails_guides/markdown/renderer.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true module RailsGuides class Markdown class Renderer < Redcarpet::Render::HTML diff --git a/guides/w3c_validator.rb b/guides/w3c_validator.rb index a97599ad3b..4671e040ca 100644 --- a/guides/w3c_validator.rb +++ b/guides/w3c_validator.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # --------------------------------------------------------------------------- # # This script validates the generated guides against the W3C Validator. -- cgit v1.2.3 From b6929552148c42f6d9687957d316c0ee555f246d Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 1 Jul 2017 22:29:41 +0900 Subject: Add missing http status codes [ci skip] Ref: https://github.com/rack/rack/commit/5401f776f660b1f8d0e0650ba78478d7488eff75, https://github.com/rack/rack/commit/73e08279d4433ca66cf22157a40dba562629031a --- guides/source/layouts_and_rendering.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index 57e603ec0d..76b325d0bf 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -379,6 +379,7 @@ Rails understands both numeric status codes and the corresponding symbols shown | | 415 | :unsupported_media_type | | | 416 | :range_not_satisfiable | | | 417 | :expectation_failed | +| | 421 | :misdirected_request | | | 422 | :unprocessable_entity | | | 423 | :locked | | | 424 | :failed_dependency | @@ -386,6 +387,7 @@ Rails understands both numeric status codes and the corresponding symbols shown | | 428 | :precondition_required | | | 429 | :too_many_requests | | | 431 | :request_header_fields_too_large | +| | 451 | :unavailable_for_legal_reasons | | **Server Error** | 500 | :internal_server_error | | | 501 | :not_implemented | | | 502 | :bad_gateway | -- cgit v1.2.3 From 6a8d618b5940b896a6b70378109433e84c885004 Mon Sep 17 00:00:00 2001 From: Sage Ross Date: Fri, 7 Jul 2017 23:10:23 -0700 Subject: Clarify i18n guide for how pluralization rules work by default The guide misleadingly indicates that the I18n gem will apply the CLDR pluralization rules for each language. This is not the case; only the English algorithm, with support for :zero, :one, and :other, is available by default. Locale-specific pluralization rules require additional configuration and must be supplied by the application (or by another gem). --- guides/source/i18n.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/i18n.md b/guides/source/i18n.md index 6c8706bc13..aa2b7d1ba9 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -701,9 +701,11 @@ end ### Pluralization -In English there are only one singular and one plural form for a given string, e.g. "1 message" and "2 messages". Other languages ([Arabic](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ar), [Japanese](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ja), [Russian](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ru) and many more) have different grammars that have additional or fewer [plural forms](http://cldr.unicode.org/index/cldr-spec/plural-rules). Thus, the I18n API provides a flexible pluralization feature. +In many languages — including English — there are only two forms, a singular and a plural, for +a given string, e.g. "1 message" and "2 messages". Other languages ([Arabic](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ar), [Japanese](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ja), [Russian](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ru) and many more) have different grammars that have additional or fewer [plural forms](http://cldr.unicode.org/index/cldr-spec/plural-rules). Thus, the I18n API provides a flexible pluralization feature. -The `:count` interpolation variable has a special role in that it both is interpolated to the translation and used to pick a pluralization from the translations according to the pluralization rules defined by CLDR: +The `:count` interpolation variable has a special role in that it both is interpolated to the translation and used to pick a pluralization from the translations according to the pluralization rules defined in the +pluralization backend. By default, only the English pluralization rules are applied. ```ruby I18n.backend.store_translations :en, inbox: { @@ -733,6 +735,22 @@ The translation denoted as `:one` is regarded as singular, and the `:other` is u If the lookup for the key does not return a Hash suitable for pluralization, an `I18n::InvalidPluralizationData` exception is raised. +#### Locale-specific rules + +The I18n gem provides a Pluralization backend that can be used to enable locale-specific rules. Include it +to the Simple backend, then add the localized pluralization algorithms to translation store, as `i18n.plural.rule`. + +```ruby +I18n::Backend::Simple.include(I18n::Backend::Pluralization) +I18n.backend.store_translations :pt, i18n: { plural: { rule: lambda { |n| [0, 1].include?(n) ? :one : :other } } } +I18n.backend.store_translations :pt, apples: { one: 'one or none', other: 'more than one' } + +I18n.t :apples, count: 0, locale: :pt +# => 'one or none' +``` + +Alternatively, the separate gem [rails-i18n](https://github.com/svenfuchs/rails-i18n) can be used to provide a fuller set of locale-specific pluralization rules. + ### Setting and Passing a Locale The locale can be either set pseudo-globally to `I18n.locale` (which uses `Thread.current` like, e.g., `Time.zone`) or can be passed as an option to `#translate` and `#localize`. -- cgit v1.2.3 From 4f7b7c987966ef5f5963ce0f9ac1e67f0a78c987 Mon Sep 17 00:00:00 2001 From: Daniel Castro Date: Sun, 9 Jul 2017 12:15:56 -0400 Subject: [ci skip] Updated language on validations. --- guides/source/active_record_basics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 6b3aa471f9..2ac80d8f89 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -314,8 +314,8 @@ already in the database, follows a specific format and many more. Validation is a very important issue to consider when persisting to the database, so the methods `save` and `update` take it into account when -running: they return `false` when validation fails and they didn't actually -perform any operation on the database. All of these have a bang counterpart (that +running: they return `false` when validation fails and they don't actually +perform any operations on the database. All of these have a bang counterpart (that is, `save!` and `update!`), which are stricter in that they raise the exception `ActiveRecord::RecordInvalid` if validation fails. A quick example to illustrate: -- cgit v1.2.3