From 30433253eda59656b1060d6ccc5e1b8e5913c331 Mon Sep 17 00:00:00 2001 From: Kirill Zhuravlov Date: Wed, 23 Nov 2016 03:04:55 +0200 Subject: Add link to API documentation Add a link to http://api.rubyonrails.org/classes/ActionController.html in the beginning of an article. --- guides/source/action_controller_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 40eb838d32..69c4a00c5f 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -61,7 +61,7 @@ end The [Layouts & Rendering Guide](layouts_and_rendering.html) explains this in more detail. -`ApplicationController` inherits from `ActionController::Base`, which defines a number of helpful methods. This guide will cover some of these, but if you're curious to see what's in there, you can see all of them in the API documentation or in the source itself. +`ApplicationController` inherits from `ActionController::Base`, which defines a number of helpful methods. This guide will cover some of these, but if you're curious to see what's in there, you can see all of them in the [API documentation](http://api.rubyonrails.org/classes/ActionController.html) or in the source itself. Only public methods are callable as actions. It is a best practice to lower the visibility of methods (with `private` or `protected`) which are not intended to be actions, like auxiliary methods or filters. -- cgit v1.2.3 From ff7a0efced5f267752a7dfd9f3e63322391fc5b7 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Tue, 21 Feb 2017 22:23:37 +0530 Subject: Add first draft of release notes for Rails 5.1 :tada: [ci skip] --- guides/source/5_1_release_notes.md | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 guides/source/5_1_release_notes.md (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md new file mode 100644 index 0000000000..6733426aaa --- /dev/null +++ b/guides/source/5_1_release_notes.md @@ -0,0 +1,98 @@ +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** + +Ruby on Rails 5.1 Release Notes +=============================== + +Highlights in Rails 5.1: + +* Yarn Support +* Optional Webpack support +* jQuery no longer a default dependency +* System tests +* Encrypted secrets +* Parameterized mailers +* Direct & resolved routes +* Unification of form_for and form_tag into form_with + +These release notes cover only the major changes. To learn about various bug +fixes and changes, please refer to the change logs or check out the [list of +commits](https://github.com/rails/rails/commits/5-1-stable) in the main Rails +repository on GitHub. + +-------------------------------------------------------------------------------- + +Upgrading to Rails 5.1 +---------------------- + +ToDo + +Major Features +-------------- + +### Yarn Support + +### System tests + +### Encrypted secrets + +### Parameterized mailers + +### Direct & resolved routes + +Railties +-------- + +Please refer to the [Changelog][railties] for detailed changes. + +Action Pack +----------- + +Please refer to the [Changelog][action-pack] for detailed changes. + +Action View +------------- + +Please refer to the [Changelog][action-view] for detailed changes. + +Action Mailer +------------- + +Please refer to the [Changelog][action-mailer] for detailed changes. + +Active Record +------------- + +Please refer to the [Changelog][active-record] for detailed changes. + +Active Model +------------ + +Please refer to the [Changelog][active-model] for detailed changes. + +Active Job +----------- + +Please refer to the [Changelog][active-job] for detailed changes. + +Active Support +-------------- + +Please refer to the [Changelog][active-support] for detailed changes. + +Credits +------- + +See the +[full list of contributors to Rails](http://contributors.rubyonrails.org/) for +the many people who spent many hours making Rails, the stable and robust +framework it is. Kudos to all of them. + +[railties]: https://github.com/rails/rails/blob/5-1-stable/railties/CHANGELOG.md +[action-pack]: https://github.com/rails/rails/blob/5-1-stable/actionpack/CHANGELOG.md +[action-view]: https://github.com/rails/rails/blob/5-1-stable/actionview/CHANGELOG.md +[action-mailer]: https://github.com/rails/rails/blob/5-1-stable/actionmailer/CHANGELOG.md +[action-cable]: https://github.com/rails/rails/blob/5-1-stable/actioncable/CHANGELOG.md +[active-record]: https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md +[active-model]: https://github.com/rails/rails/blob/5-1-stable/activemodel/CHANGELOG.md +[active-support]: https://github.com/rails/rails/blob/5-1-stable/activesupport/CHANGELOG.md +[active-job]: https://github.com/rails/rails/blob/5-1-stable/activejob/CHANGELOG.md -- cgit v1.2.3 From d8fd067969c4be4d8c38624a7cb79f770e087760 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Tue, 21 Feb 2017 22:38:30 +0530 Subject: Add PR links for major features [ci skip] --- guides/source/5_1_release_notes.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 6733426aaa..f195922dca 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -31,14 +31,25 @@ Major Features ### Yarn Support +[Pull Request](https://github.com/rails/rails/pull/26836) + ### System tests +[Pull Request](https://github.com/rails/rails/pull/26703) + ### Encrypted secrets +[Pull Request](https://github.com/rails/rails/pull/28038) + ### Parameterized mailers +[Pull Request](https://github.com/rails/rails/pull/27825) + ### Direct & resolved routes +[Pull Request](https://github.com/rails/rails/pull/23138) + + Railties -------- -- cgit v1.2.3 From e1567d0d3a3c0ae1f4da1fb8b5b77a85767fb6ae Mon Sep 17 00:00:00 2001 From: Krzysztof Maicher Date: Sat, 4 Mar 2017 17:26:23 +0100 Subject: Improve foreign key description in guides [ci skip] --- guides/source/association_basics.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 73c9c10c1f..5794bfa666 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -582,14 +582,30 @@ class CreateBooks < ActiveRecord::Migration[5.0] t.string :book_number t.integer :author_id end - - add_index :books, :author_id end end ``` If you create an association some time after you build the underlying model, you need to remember to create an `add_column` migration to provide the necessary foreign key. +It's a good practice to add an index on the foreign key to improve queries +performance and a foreign key constraint to ensure referential data integrity: + +```ruby +class CreateBooks < ActiveRecord::Migration[5.0] + def change + create_table :books do |t| + t.datetime :published_at + t.string :book_number + t.integer :author_id + end + + add_index :books, :author_id + add_foreign_key :books, :authors + end +end +``` + #### Creating Join Tables for `has_and_belongs_to_many` Associations If you create a `has_and_belongs_to_many` association, you need to explicitly create the joining table. Unless the name of the join table is explicitly specified by using the `:join_table` option, Active Record creates the name by using the lexical book of the class names. So a join between author and book models will give the default join table name of "authors_books" because "a" outranks "b" in lexical ordering. -- cgit v1.2.3 From 12cadc6f62da270eb7d9cfb010450f4123da75df Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 7 Mar 2017 15:40:52 +0900 Subject: Remove `:on` option that does ot exist [ci skip] That option was removed in 0a683085b1db435b7371350b2799a0f248cd717a --- guides/source/testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 3f53ccb242..4caf55ab12 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -658,8 +658,8 @@ 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 for non-headless drivers like Selenium), `:on` for the port Puma should -use, and `:screen_size` to change the size of the screen for screenshots. +be used for non-headless drivers like Selenium), and `:screen_size` to change +the size of the screen for screenshots. ```ruby require "test_helper" -- cgit v1.2.3 From ac00659b1b2a5d410b6b12615279c7c058a72fe1 Mon Sep 17 00:00:00 2001 From: Shia Date: Wed, 8 Mar 2017 10:54:06 +0900 Subject: Fix to use correct path with language on guide --- guides/rails_guides/generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb index 28164a3cb4..35f014747c 100644 --- a/guides/rails_guides/generator.rb +++ b/guides/rails_guides/generator.rb @@ -73,7 +73,7 @@ module RailsGuides @output_dir = "#{@guides_dir}/output" @output_dir += "/kindle" if @kindle - @source_dir += "/#{@language}" if @language + @output_dir += "/#{@language}" if @language end def create_output_dir_if_needed -- cgit v1.2.3 From 37770bc8d13c5c7af024e66539c79f966718aec0 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 9 Mar 2017 09:22:33 +0100 Subject: force UTF-8 as external encoding in guides generation [ci skip] See the rationale in the comment found in the patch. --- guides/Rakefile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/Rakefile b/guides/Rakefile index ccb42f3273..0a591558e1 100644 --- a/guides/Rakefile +++ b/guides/Rakefile @@ -2,15 +2,28 @@ namespace :guides do desc 'Generate guides (for authors), use ONLY=foo to process just "foo.md"' task generate: "generate:html" + # Guides are written in UTF-8, but the environment may be configured for some + # other locale, these tasks are responsible for ensuring the default external + # encoding is UTF-8. + # + # Real use cases: Generation was reported to fail on a machine configured with + # GBK (Chinese). The docs server once got misconfigured somehow and had "C", + # which broke generation too. + task :encoding do + %w(LANG LANGUAGE LC_ALL).each do |env_var| + ENV[env_var] = "en_US.UTF-8" + end + end + namespace :generate do desc "Generate HTML guides" - task :html do + task :html => :encoding do ENV["WARNINGS"] = "1" # authors can't disable this ruby "rails_guides.rb" end desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211" - task :kindle do + task :kindle => :encoding do require "kindlerb" unless Kindlerb.kindlegen_available? abort "Please run `setupkindlerb` to install kindlegen" @@ -25,7 +38,7 @@ namespace :guides do # Validate guides ------------------------------------------------------------------------- desc 'Validate guides, use ONLY=foo to process just "foo.html"' - task :validate do + task :validate => :encoding do ruby "w3c_validator.rb" end -- cgit v1.2.3 From 7724c8cb53093ba09f5b8f08feb8321d376d56dd Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Thu, 9 Mar 2017 20:05:13 +0530 Subject: Edits to Systems testing section [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 f7640d097f..ada7c2da76 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -644,7 +644,7 @@ system tests should live. If you want to change the default settings you can simply change what the system tests are "driven by". Say you want to change the driver from Selenium to -Poltergeist. First add the Poltergeist gem to your Gemfile. Then in your +Poltergeist. First add the `poltergeist` gem to your Gemfile. Then in your `application_system_test_case.rb` file do the following: ```ruby @@ -722,7 +722,7 @@ class ArticlesTest < ApplicationSystemTestCase end ``` -The test should see that there is an h1 on the articles index and pass. +The test should see that there is an `h1` on the articles index page and pass. Run the system tests. @@ -760,7 +760,7 @@ text. Once the fields are filled in, "Create Article" is clicked on which will send a POST request to create the new article in the database. We will be redirected back to the the articles index page and there we assert -that the text from the article title is on the articles index page. +that the text from the new article's title is on the articles index page. #### Taking it further -- cgit v1.2.3 From dcc9bd35e248f9e038c0fbc6a2024cd2d5228cbc Mon Sep 17 00:00:00 2001 From: James Baer Date: Fri, 10 Mar 2017 12:33:21 -0500 Subject: Improve readability of testing guide [ci skip] Small change to improve the readability in section 2.3 of the testing guide. --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 4caf55ab12..27f5b5e916 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -123,7 +123,7 @@ def test_the_truth end ``` -However only the `test` macro allows a more readable test name. You can still use regular method definitions though. +Although you can still use regular method definitions, using the `test` macro allows for a more readable test name. NOTE: The method name is generated by replacing spaces with underscores. The result does not need to be a valid Ruby identifier though, the name may contain punctuation characters etc. That's because in Ruby technically any string may be a method name. This may require use of `define_method` and `send` calls to function properly, but formally there's little restriction on the name. -- cgit v1.2.3 From 5c2678056ac5d7af1a2f82a6e1e98401467cb5eb Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Sun, 12 Mar 2017 12:06:48 +0200 Subject: Fix typo in the security guide [ci skip] --- guides/source/security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/security.md b/guides/source/security.md index a81a782cf2..a57c6ea247 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -615,7 +615,7 @@ The two dashes start a comment ignoring everything after it. So the query return Usually a web application includes access control. The user enters their login credentials and the web application tries to find the matching record in the users table. The application grants access when it finds a record. However, an attacker may possibly bypass this check with SQL injection. The following shows a typical database query in Rails to find the first record in the users table which matches the login credentials parameters supplied by the user. ```ruby -User.first("login = '#{params[:name]}' AND password = '#{params[:password]}'") +User.find_by("login = '#{params[:name]}' AND password = '#{params[:password]}'") ``` If an attacker enters ' OR '1'='1 as the name, and ' OR '2'>'1 as the password, the resulting SQL query will be: @@ -762,7 +762,7 @@ s = sanitize(user_input, tags: tags, attributes: %w(href title)) This allows only the given tags and does a good job, even against all kinds of tricks and malformed tags. -As a second step, _it is good practice to escape all output of the application_, especially when re-displaying user input, which hasn't been input-filtered (as in the search form example earlier on). _Use `escapeHTML()` (or its alias `h()`) method_ to replace the HTML input characters &, ", <, and > by their uninterpreted representations in HTML (`&`, `"`, `<`, and `>`). +As a second step, _it is good practice to escape all output of the application_, especially when re-displaying user input, which hasn't been input-filtered (as in the search form example earlier on). _Use `escapeHTML()` (or its alias `h()`) method_ to replace the HTML input characters &, ", <, and > by their uninterpreted representations in HTML (`&`, `"`, `<`, and `>`). ##### Obfuscation and Encoding Injection -- cgit v1.2.3 From 4d5060072b5446e0d13873f7edbecaf3527e7846 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sun, 12 Mar 2017 19:37:48 +0530 Subject: Add link to mentioned API [ci skip] (#28392) --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 8ad76ad01e..0508b0fb38 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -531,7 +531,7 @@ To leverage time zone support in Rails, you have to ask your users what time zon <%= time_zone_select(:person, :time_zone) %> ``` -There is also `time_zone_options_for_select` helper for a more manual (therefore more customizable) way of doing this. Read the API documentation to learn about the possible arguments for these two methods. +There is also `time_zone_options_for_select` helper for a more manual (therefore more customizable) way of doing this. Read the [API documentation](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-time_zone_options_for_select) to learn about the possible arguments for these two methods. Rails _used_ to have a `country_select` helper for choosing countries, but this has been extracted to the [country_select plugin](https://github.com/stefanpenner/country_select). When using this, be aware that the exclusion or inclusion of certain names from the list can be somewhat controversial (and was the reason this functionality was extracted from Rails). -- cgit v1.2.3 From 8f9241b076c836a318649f26e7677ae1390c3b9a Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 12 Mar 2017 11:25:24 -0400 Subject: First editing pass on "Active Model Basics" guide Lots of grammar, etc fixes. [ci skip] --- guides/source/active_model_basics.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'guides') diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index 72daa29f7f..a35d0e4067 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -87,7 +87,7 @@ end ### Conversion If a class defines `persisted?` and `id` methods, then you can include the -`ActiveModel::Conversion` module in that class and call the Rails conversion +`ActiveModel::Conversion` module in that class, and call the Rails conversion methods on objects of that class. ```ruby @@ -132,7 +132,7 @@ class Person end def last_name - @last_name + @last_nameperson.changes # => {"first_name"=>[nil, "First Name"]} end def last_name=(value) @@ -156,16 +156,17 @@ person.changed? # => false person.first_name = "First Name" person.first_name # => "First Name" -# returns true if any of the attributes have unsaved changes, false otherwise. +# returns true if any of the attributes have unsaved changes. person.changed? # => true # returns a list of attributes that have changed before saving. person.changed # => ["first_name"] -# returns a hash of the attributes that have changed with their original values. +# returns a Hash of the attributes that have changed with their original values. person.changed_attributes # => {"first_name"=>nil} -# returns a hash of changes, with the attribute names as the keys, and the values will be an array of the old and new value for that field. +# returns a Hash of changes, with the attribute names as the keys, and the +# values as an array of the old and new values for that field. person.changes # => {"first_name"=>[nil, "First Name"]} ``` @@ -179,7 +180,7 @@ person.first_name # => "First Name" person.first_name_changed? # => true ``` -Track what was the previous value of the attribute. +Track the previous value of the attribute. ```ruby # attr_name_was accessor @@ -187,7 +188,7 @@ person.first_name_was # => nil ``` Track both previous and current value of the changed attribute. Returns an array -if changed, else returns nil. +if changed, otherwise returns nil. ```ruby # attr_name_change @@ -197,7 +198,7 @@ person.last_name_change # => nil ### Validations -The `ActiveModel::Validations` module adds the ability to validate class objects +The `ActiveModel::Validations` module adds the ability to validate objects like in Active Record. ```ruby @@ -225,7 +226,7 @@ person.valid? # => raises ActiveModel::StrictValidationFa ### Naming -`ActiveModel::Naming` adds a number of class methods which make the naming and routing +`ActiveModel::Naming` adds a number of class methods which make naming and routing easier to manage. The module defines the `model_name` class method which will define a number of accessors using some `ActiveSupport::Inflector` methods. @@ -248,7 +249,7 @@ Person.model_name.singular_route_key # => "person" ### Model -`ActiveModel::Model` adds the ability to a class to work with Action Pack and +`ActiveModel::Model` adds the ability for a class to work with Action Pack and Action View right out of the box. ```ruby @@ -308,7 +309,7 @@ class Person end ``` -Now you can access a serialized hash of your object using the `serializable_hash`. +Now you can access a serialized hash of your object using the `serializable_hash` method. ```ruby person = Person.new -- cgit v1.2.3 From 21a44916ae39cb622c11c3e206a74925d114cfa8 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 12 Mar 2017 11:37:15 -0400 Subject: Second editing pass on "Active Model Basics" guide Lots of grammar, etc fixes. [ci skip] --- guides/source/active_model_basics.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'guides') diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index a35d0e4067..ce33734f41 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -294,7 +294,7 @@ objects. ### Serialization `ActiveModel::Serialization` provides basic serialization for your object. -You need to declare an attributes hash which contains the attributes you want to +You need to declare an attributes Hash which contains the attributes you want to serialize. Attributes must be strings, not symbols. ```ruby @@ -309,7 +309,7 @@ class Person end ``` -Now you can access a serialized hash of your object using the `serializable_hash` method. +Now you can access a serialized Hash of your object using the `serializable_hash` method. ```ruby person = Person.new @@ -320,13 +320,14 @@ person.serializable_hash # => {"name"=>"Bob"} #### ActiveModel::Serializers -Rails provides an `ActiveModel::Serializers::JSON` serializer. -This module automatically includes the `ActiveModel::Serialization`. +Active Model also provides the `ActiveModel::Serializers::JSON` module +for JSON serializing / deserializing. This module automatically includes the +previously discussed `ActiveModel::Serialization` module. ##### ActiveModel::Serializers::JSON -To use the `ActiveModel::Serializers::JSON` you only need to change from -`ActiveModel::Serialization` to `ActiveModel::Serializers::JSON`. +To use `ActiveModel::Serializers::JSON` you only need to change the +module you are including from `ActiveModel::Serialization` to `ActiveModel::Serializers::JSON`. ```ruby class Person @@ -340,7 +341,8 @@ class Person end ``` -With the `as_json` method you have a hash representing the model. +The `as_json` method, similar to `serializable_hash`, provides a Hash representing +the model. ```ruby person = Person.new @@ -349,8 +351,8 @@ person.name = "Bob" person.as_json # => {"name"=>"Bob"} ``` -From a JSON string you define the attributes of the model. -You need to have the `attributes=` method defined on your class: +You can also define the attributes for a model from a JSON string. +However, you need to define the `attributes=` method on your class: ```ruby class Person @@ -370,7 +372,7 @@ class Person end ``` -Now it is possible to create an instance of person and set the attributes using `from_json`. +Now it is possible to create an instance of `Person` and set attributes using `from_json`. ```ruby json = { name: 'Bob' }.to_json @@ -390,8 +392,8 @@ class Person end ``` -With the `human_attribute_name` you can transform attribute names into a more -human format. The human format is defined in your locale file. +With the `human_attribute_name` method, you can transform attribute names into a +more human-readable format. The human-readable format is defined in your locale file(s). * config/locales/app.pt-BR.yml @@ -412,7 +414,7 @@ Person.human_attribute_name('name') # => "Nome" `ActiveModel::Lint::Tests` allows you to test whether an object is compliant with the Active Model API. -* app/models/person.rb +* `app/models/person.rb` ```ruby class Person @@ -420,7 +422,7 @@ the Active Model API. end ``` -* test/models/person_test.rb +* `test/models/person_test.rb` ```ruby require 'test_helper' @@ -455,9 +457,9 @@ features out of the box. ### SecurePassword `ActiveModel::SecurePassword` provides a way to securely store any -password in an encrypted form. On including this module, a +password in an encrypted form. When you include this module, a `has_secure_password` class method is provided which defines -an accessor named `password` with certain validations on it. +a `password` accessor with certain validations on it. #### Requirements -- cgit v1.2.3 From 89d66410892b9c42bf2a11f7308d6c8bf8d656c8 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 12 Mar 2017 13:11:53 -0400 Subject: Fix weird documentation line [ci skip] --- guides/source/active_model_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index ce33734f41..e26805d22c 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -132,7 +132,7 @@ class Person end def last_name - @last_nameperson.changes # => {"first_name"=>[nil, "First Name"]} + @last_name end def last_name=(value) -- cgit v1.2.3 From b4dbe8c7338f0b531d60dbae12031a51ab7a7dcc Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Fri, 3 Mar 2017 12:31:31 +0530 Subject: Add blurbs about each new feature [ci skip] --- guides/source/5_1_release_notes.md | 158 +++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index f195922dca..f3c8f1f155 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -33,22 +33,180 @@ Major Features [Pull Request](https://github.com/rails/rails/pull/26836) +Rails 5.1 will allow managing JavaScript dependencies +from NPM via Yarn.This will make it easy to use libraries like React, VueJS +or any other library from NPM world. The Yarn support is integrated with +the asset pipeline so that all dependencies will work seamlessly with the +Rails 5.1 app. + +### Optional Webpack support + +Rails apps can use Webpack easily now using the [Webpacker](https://github.com/rails/webpacker) +gem. New Rails 5.1 app can be generated using `--webpack` switch to enable Webpack integration. + +This is fully compatible with the asset pipeline, which you can continue to use for +images, fonts, sounds, whatever. You can even have some JavaScript on the asset pipeline +and some done via Webpack. It’s all managed via Yarn that’s on by default. + +### jQuery no longer a default dependency + +jQuery was required by default in earlier versions of Rails to provide features like +`data-remote`, `data-confirm` and other parts of Rails UJS. It is no longer required, +as the `rails-ujs` is now written using plain vanilla JavaScript. + +You can still use jQuery if needed, but it is no longer required by default. + ### System tests [Pull Request](https://github.com/rails/rails/pull/26703) +Rails 5.1 has support for writing Capybara tests baked in in the form of +System tests. Now you don't have to worry about configuring Capybara and +database cleaning strategies for such tests. Rails 5.1 provides a wrapper +for running such tests in chrome with additional features such as failure +screenshots. + ### Encrypted secrets [Pull Request](https://github.com/rails/rails/pull/28038) +Rails will now allow management of application secrets in a secure way +built on top of [sekrets](https://github.com/ahoward/sekrets) gem. + +Run `bin/rails secrets:setup` to setup a new encrypted secrets file. It will +generate a master key which needs to be stored outside of the repository and it will +allow checking in the actual secrets in the revision control. + +The secrets will be decrypted in production either using `RAILS_MASTER_KEY` from +the ENV or injected key file. + ### Parameterized mailers [Pull Request](https://github.com/rails/rails/pull/27825) +Allows specifying common params used for all methods in a mailer class +to share instance variables, headers and other common setup. + +``` ruby +class InvitationsMailer < ApplicationMailer + + before_action { @inviter, @invitee = params[:inviter], params[:invitee] } + before_action { @account = params[:inviter].account } + + def account_invitation + mail subject: "#{@inviter.name} invited you to their Basecamp (#{@account.name})" + end + + def project_invitation + @project = params[:project] + @summarizer = ProjectInvitationSummarizer.new(@project.bucket) + + mail subject: "#{@inviter.name.familiar} added you to a project in Basecamp (#{@account.name})" + end +end + +InvitationsMailer.with(inviter: person_a, invitee: person_b).account_invitation.deliver_later +``` + ### Direct & resolved routes [Pull Request](https://github.com/rails/rails/pull/23138) +Rails 5.1 has added two new methods - `resolve` and `direct` to the routing +DSL. + +The `resolve` method allows customizing polymorphic mapping of models. + +``` ruby +resource :basket + +resolve(class: "Basket") { [:basket] } +``` + +``` erb +<%= form_for @basket do |form| %> + +<% end %> +``` + +This will generate the singular URL `/basket` instead of usual `/baskets/:id`. + +The `direct` method allows creation of custom URL helpers. + +``` ruby +direct(:homepage) { "http://www.rubyonrails.org" } + +>> homepage_url +=> "http://www.rubyonrails.org" +``` + +The return value of the block must be a valid argument for the `url_for` +method. So you can pass a valid string URL, or a hash, or an array, or an +Active Model instance or an Active Model class. + +``` ruby +direct :commentable do |model| + [ model, anchor: model.dom_id ] +end + +direct :main do + { controller: 'pages', action: 'index', subdomain: 'www' } +end +``` + +### Unification of form_for and form_tag into form_with + +[Pull Request](https://github.com/rails/rails/pull/26976) + +Before Rails 5.1, there were two interfaces for handling HTML forms, +`form_for` for model instances and `form_tag` for custom URLs. + +Rails 5.1 combines both of these interfaces with `form_with` and +can generate form tags based on URLs, scopes or models. + +``` erb +# Using just a URL: + +<%= form_with url: posts_path do |form| %> + <%= form.text_field :title %> +<% end %> + +# => +
+ +
+ +# Adding a scope prefixes the input field names: + +<%= form_with scope: :post, url: posts_path do |form| %> + <%= form.text_field :title %> +<% end %> +# => +
+ +
+ +# Using a model infers both the URL and scope: + +<%= form_with model: Post.new do |form| %> + <%= form.text_field :title %> +<% end %> +# => +
+ +
+ +# An existing model makes an update form and fills out field values: + +<%= form_with model: Post.first do |form| %> + <%= form.text_field :title %> +<% end %> +# => +
+ + +
+``` Railties -------- -- cgit v1.2.3 From 96c525f2509a9ec1890c5218f6a65b22660b97f7 Mon Sep 17 00:00:00 2001 From: Philipe Fatio Date: Tue, 14 Mar 2017 10:57:50 +0100 Subject: Remove obsolete warning about regular expression This warning became obsolete when the regular expression was changed to use `\z` instead of `\Z` in fce9c4e5e1ecb31cff2ca43a04fbe332816c3c45. "-1234\n" =~ /\A[+-]?\d+\Z/ => 0 "-1234\n" =~ /\A[+-]?\d+\z/ => nil [ci skip] --- guides/source/active_record_validations.md | 3 --- 1 file changed, 3 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 32b38cde5e..5313361dfd 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -490,9 +490,6 @@ If you set `:only_integer` to `true`, then it will use the regular expression to validate the attribute's value. Otherwise, it will try to convert the value to a number using `Float`. -WARNING. Note that the regular expression above allows a trailing newline -character. - ```ruby class Player < ApplicationRecord validates :points, numericality: true -- cgit v1.2.3 From a05845e0a699e169c11962212200dc8e72934dff Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Wed, 15 Mar 2017 12:14:46 +0000 Subject: Remove unused `@txn` variable This was added in c24c885209ac2334dc6f798c394a821ee270bec6, removed in b89ffe7f0047eb614e42232a21201b317b880755, and then (unintentionally?) reintroduced in 2d7ae1b08ee2a10b12cbfeef3a6cc6da55b57df6. --- guides/source/debugging_rails_applications.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides') diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index ba0cdbf3af..33dee6a868 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -606,7 +606,6 @@ You can also inspect for an object method this way: @new_record = true @readonly = false @transaction_state = nil -@txn = nil ``` You can also use `display` to start watching variables. This is a good way of -- cgit v1.2.3 From dcd6ceb0c90866272b3e75f9d34ef9f13cfb33c6 Mon Sep 17 00:00:00 2001 From: marksiemers Date: Wed, 15 Mar 2017 12:38:49 -0700 Subject: Update 'Building Complex Forms' with `inverse_of` If the example for complex forms is implemented, ActiveRecord will prevent saving unless `inverse_of: :person` is added to the `has_many :addresses` association. --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 0508b0fb38..95c2e33dc7 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -877,7 +877,7 @@ Active Record provides model level support via the `accepts_nested_attributes_fo ```ruby class Person < ApplicationRecord - has_many :addresses + has_many :addresses, inverse_of: :person accepts_nested_attributes_for :addresses end -- cgit v1.2.3 From 5a072ba317aa180b3622145003fb3ed8b93d226f Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Tue, 7 Mar 2017 00:09:55 +0200 Subject: Remove ability update locking_column value --- guides/source/active_record_querying.md | 3 --- 1 file changed, 3 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 31865ea375..2902c5d677 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -953,9 +953,6 @@ class Client < ApplicationRecord end ``` -NOTE: Please note that the optimistic locking will be ignored if you update the -locking column's value. - ### Pessimistic Locking Pessimistic locking uses a locking mechanism provided by the underlying database. Using `lock` when building a relation obtains an exclusive lock on the selected rows. Relations using `lock` are usually wrapped inside a transaction for preventing deadlock conditions. -- cgit v1.2.3 From 5a09b3fd6b22dda7b77dfa47d6ace210ea84f43a Mon Sep 17 00:00:00 2001 From: marvin Date: Thu, 16 Mar 2017 19:42:00 +0800 Subject: Fix asset_pipeline docs incorrect image dir info --- guides/source/asset_pipeline.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 68dde4482f..61b7112247 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -335,7 +335,7 @@ an asset has been updated and if so loads it into the page: <%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %> ``` -In regular views you can access images in the `public/assets/images` directory +In regular views you can access images in the `app/assets/images` directory like this: ```erb -- cgit v1.2.3 From 7b02f86680b2d712ea5b0ca541dc620f0a524b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 17 Mar 2017 13:14:51 -0400 Subject: Fix resolve usage in the release notes [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index f3c8f1f155..6bd5321b92 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -120,7 +120,7 @@ The `resolve` method allows customizing polymorphic mapping of models. ``` ruby resource :basket -resolve(class: "Basket") { [:basket] } +resolve("Basket") { [:basket] } ``` ``` erb -- cgit v1.2.3 From da7c4126d34c358cd83a0343af800c1c3d4ac5d8 Mon Sep 17 00:00:00 2001 From: James Baer Date: Fri, 17 Mar 2017 16:02:24 -0400 Subject: Improve Caching with Rails Guides [ci skip] Adds the "Caching in Development" section to demonstrate usage of the dev:cache task in development mode. Also, makes a small grammatical correction in section 2.4. --- guides/source/caching_with_rails.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index fd7626250c..af4ef6a58d 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -396,7 +396,7 @@ config.cache_store = :file_store, "/path/to/cache/directory" ``` With this cache store, multiple server processes on the same host can share a -cache. The cache store is appropriate for low to medium traffic sites that are +cache. This cache store is appropriate for low to medium traffic sites that are served off one or two hosts. Server processes running on different hosts could share a cache by using a shared file system, but that setup is not recommended. @@ -570,6 +570,20 @@ You can also set the strong ETag directly on the response. response.strong_etag = response.body # => "618bbc92e2d35ea1945008b42799b0e7" ``` +Caching in Development +---------------------- + +It's common to want to test the caching strategy of your application +in developement mode. Rails provides the rake task `dev:cache` to +easily toggle caching on/off. + +```bash +$ bin/rails dev:cache +Development mode is now being cached. +$ bin/rails dev:cache +Development mode is no longer being cached. +``` + References ---------- -- cgit v1.2.3 From 33786f62f9a1f9bd855bc51da501fb6a0fd6d0bf Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 18 Mar 2017 22:07:20 -0400 Subject: First pass on 5.1 release notes Fixing tons of grammar, etc. [ci skip] --- guides/source/5_1_release_notes.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 6bd5321b92..5b46cc57b2 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -41,20 +41,24 @@ Rails 5.1 app. ### Optional Webpack support -Rails apps can use Webpack easily now using the [Webpacker](https://github.com/rails/webpacker) -gem. New Rails 5.1 app can be generated using `--webpack` switch to enable Webpack integration. +Rails apps can integrate with [Webpack](https://webpack.js.org/), a JavaScript +asset bundler, more easily using the new [Webpacker](https://github.com/rails/webpacker) +gem. Use the `--webpack` flag when generating new applications to enable Webpack +integration. This is fully compatible with the asset pipeline, which you can continue to use for -images, fonts, sounds, whatever. You can even have some JavaScript on the asset pipeline -and some done via Webpack. It’s all managed via Yarn that’s on by default. +images, fonts, sounds, and other assets. You can even have some JavaScript code +managed by the asset pipeline, and other code processed via Webpack. It’s all managed via Yarn that’s on by default. ### jQuery no longer a default dependency -jQuery was required by default in earlier versions of Rails to provide features like -`data-remote`, `data-confirm` and other parts of Rails UJS. It is no longer required, -as the `rails-ujs` is now written using plain vanilla JavaScript. +jQuery was required by default in earlier versions of Rails to provide features +like `data-remote`, `data-confirm` and other parts of Rails' Unobtrusive JavaScript +offerings. It is no longer required, as the UJS has been rewritten to use plain, +vanilla JavaScript. This code now ships inside of Action View as +`rails-ujs`. -You can still use jQuery if needed, but it is no longer required by default. +You can still use jQuery version if needed, but it is no longer required by default. ### System tests @@ -63,7 +67,7 @@ You can still use jQuery if needed, but it is no longer required by default. Rails 5.1 has support for writing Capybara tests baked in in the form of System tests. Now you don't have to worry about configuring Capybara and database cleaning strategies for such tests. Rails 5.1 provides a wrapper -for running such tests in chrome with additional features such as failure +for running tests in Chrome with additional features such as failure screenshots. ### Encrypted secrets @@ -71,14 +75,14 @@ screenshots. [Pull Request](https://github.com/rails/rails/pull/28038) Rails will now allow management of application secrets in a secure way -built on top of [sekrets](https://github.com/ahoward/sekrets) gem. +built on top of the [sekrets](https://github.com/ahoward/sekrets) gem. Run `bin/rails secrets:setup` to setup a new encrypted secrets file. It will -generate a master key which needs to be stored outside of the repository and it will +generate a master key which needs to be stored outside of the repository, and it will allow checking in the actual secrets in the revision control. -The secrets will be decrypted in production either using `RAILS_MASTER_KEY` from -the ENV or injected key file. +The secrets will be decrypted in production using either the `RAILS_MASTER_KEY` +environment variable from a key file. ### Parameterized mailers @@ -112,7 +116,7 @@ InvitationsMailer.with(inviter: person_a, invitee: person_b).account_invitation. [Pull Request](https://github.com/rails/rails/pull/23138) -Rails 5.1 has added two new methods - `resolve` and `direct` to the routing +Rails 5.1 has added two new methods, `resolve` and `direct`, to the routing DSL. The `resolve` method allows customizing polymorphic mapping of models. -- cgit v1.2.3 From cb12b2a075956cac23da86648028b45e8ee30f69 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 18 Mar 2017 22:09:53 -0400 Subject: Second pass on 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 5b46cc57b2..1b6eb76e32 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -133,7 +133,7 @@ resolve("Basket") { [:basket] } <% end %> ``` -This will generate the singular URL `/basket` instead of usual `/baskets/:id`. +This will generate the singular URL `/basket` instead of the usual `/baskets/:id`. The `direct` method allows creation of custom URL helpers. @@ -145,8 +145,8 @@ direct(:homepage) { "http://www.rubyonrails.org" } ``` The return value of the block must be a valid argument for the `url_for` -method. So you can pass a valid string URL, or a hash, or an array, or an -Active Model instance or an Active Model class. +method. So, you can pass a valid string URL, Hash, array, an +Active Model instance, or an Active Model class. ``` ruby direct :commentable do |model| @@ -162,10 +162,10 @@ end [Pull Request](https://github.com/rails/rails/pull/26976) -Before Rails 5.1, there were two interfaces for handling HTML forms, +Before Rails 5.1, there were two interfaces for handling HTML forms: `form_for` for model instances and `form_tag` for custom URLs. -Rails 5.1 combines both of these interfaces with `form_with` and +Rails 5.1 combines both of these interfaces with `form_with`, and can generate form tags based on URLs, scopes or models. ``` erb -- cgit v1.2.3 From 061927b4a84770c71f26e706e8720e56eed32b58 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 18 Mar 2017 22:15:27 -0400 Subject: Add link to Webpack/Webpacker PR [ci skip] --- guides/source/5_1_release_notes.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 1b6eb76e32..d072c67108 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -41,6 +41,8 @@ Rails 5.1 app. ### Optional Webpack support +[Pull Request](https://github.com/rails/rails/pull/27288) + Rails apps can integrate with [Webpack](https://webpack.js.org/), a JavaScript asset bundler, more easily using the new [Webpacker](https://github.com/rails/webpacker) gem. Use the `--webpack` flag when generating new applications to enable Webpack -- cgit v1.2.3 From 5e8dfcd12d1c496cf811a32f9f22de6a40d5abd3 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 18 Mar 2017 22:20:01 -0400 Subject: Add link to rails-ujs/dropping jQuery PR [ci skip] --- guides/source/5_1_release_notes.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index d072c67108..0216f04761 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -54,6 +54,8 @@ managed by the asset pipeline, and other code processed via Webpack. It’s all ### jQuery no longer a default dependency +[Pull Request](https://github.com/rails/rails/pull/27113) + jQuery was required by default in earlier versions of Rails to provide features like `data-remote`, `data-confirm` and other parts of Rails' Unobtrusive JavaScript offerings. It is no longer required, as the UJS has been rewritten to use plain, -- cgit v1.2.3 From 9cc2f50f9cc3191fd796af68d09826c67c02a572 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 18 Mar 2017 22:41:15 -0400 Subject: Update some jquery-ujs references to rails-ujs [ci skip] --- guides/source/action_mailer_basics.md | 5 +++-- guides/source/security.md | 13 ++++++------- guides/source/working_with_javascript_in_rails.md | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'guides') diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index 380fdac658..9673571909 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -550,8 +550,9 @@ url helper. <%= user_url(@user, host: 'example.com') %> ``` -NOTE: non-`GET` links require [jQuery UJS](https://github.com/rails/jquery-ujs) -and won't work in mailer templates. They will result in normal `GET` requests. +NOTE: non-`GET` links require [rails-ujs](https://github.com/rails/rails-ujs) or +[jQuery UJS](https://github.com/rails/jquery-ujs), and won't work in mailer templates. +They will result in normal `GET` requests. ### Adding images in Action Mailer Views diff --git a/guides/source/security.md b/guides/source/security.md index a57c6ea247..a14134f8c1 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -257,13 +257,12 @@ protect_from_forgery with: :exception This will automatically include a security token in all forms and Ajax requests generated by Rails. If the security token doesn't match what was expected, an exception will be thrown. -NOTE: By default, Rails includes jQuery and an [unobtrusive scripting adapter for -jQuery](https://github.com/rails/jquery-ujs), which adds a header called -`X-CSRF-Token` on every non-GET Ajax call made by jQuery with the security token. -Without this header, non-GET Ajax requests won't be accepted by Rails. When using -another library to make Ajax calls, it is necessary to add the security token as -a default header for Ajax calls in your library. To get the token, have a look at -`` tag printed by +NOTE: By default, Rails includes an [unobtrusive scripting adapter](https://github.com/rails/rails-ujs), +which adds a header called `X-CSRF-Token` with the security token on every non-GET +Ajax call. Without this header, non-GET Ajax requests won't be accepted by Rails. +When using another library to make Ajax calls, it is necessary to add the security +token as a default header for Ajax calls in your library. To get the token, have +a look at `` tag printed by `<%= csrf_meta_tags %>` in your application view. It is common to use persistent cookies to store user information, with `cookies.permanent` for example. In this case, the cookies will not be cleared and the out of the box CSRF protection will not be effective. If you are using a different cookie store than the session for this information, you must handle what to do with it yourself: diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index c1dfcab6f3..e04b3e3581 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -149,7 +149,7 @@ Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two parts: the JavaScript half and the Ruby half. Unless you have disabled the Asset Pipeline, -[rails.js](https://github.com/rails/jquery-ujs/blob/master/src/rails.js) +[rails-ujs](https://github.com/rails/rails-ujs/blob/master/src/rails-ujs.coffee) provides the JavaScript half, and the regular Ruby view helpers add appropriate tags to your DOM. -- cgit v1.2.3 From aa56c89eb2691ffccdd60e72d5c17118edbf1b63 Mon Sep 17 00:00:00 2001 From: Simon Dawson Date: Sun, 19 Mar 2017 08:31:49 +0000 Subject: Minor grammar fixes for Rails 5.1 release notes --- guides/source/5_1_release_notes.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 0216f04761..5d4885d55c 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -34,7 +34,7 @@ Major Features [Pull Request](https://github.com/rails/rails/pull/26836) Rails 5.1 will allow managing JavaScript dependencies -from NPM via Yarn.This will make it easy to use libraries like React, VueJS +from NPM via Yarn. This will make it easy to use libraries like React, VueJS or any other library from NPM world. The Yarn support is integrated with the asset pipeline so that all dependencies will work seamlessly with the Rails 5.1 app. @@ -50,7 +50,8 @@ integration. This is fully compatible with the asset pipeline, which you can continue to use for images, fonts, sounds, and other assets. You can even have some JavaScript code -managed by the asset pipeline, and other code processed via Webpack. It’s all managed via Yarn that’s on by default. +managed by the asset pipeline, and other code processed via Webpack. All of this is managed +by Yarn, which is enabled by default. ### jQuery no longer a default dependency @@ -62,14 +63,14 @@ offerings. It is no longer required, as the UJS has been rewritten to use plain, vanilla JavaScript. This code now ships inside of Action View as `rails-ujs`. -You can still use jQuery version if needed, but it is no longer required by default. +You can still use the jQuery version if needed, but it is no longer required by default. ### System tests [Pull Request](https://github.com/rails/rails/pull/26703) -Rails 5.1 has support for writing Capybara tests baked in in the form of -System tests. Now you don't have to worry about configuring Capybara and +Rails 5.1 has baked-in support for writing Capybara tests, in the form of +System tests. You need no longer worry about configuring Capybara and database cleaning strategies for such tests. Rails 5.1 provides a wrapper for running tests in Chrome with additional features such as failure screenshots. @@ -78,15 +79,16 @@ screenshots. [Pull Request](https://github.com/rails/rails/pull/28038) -Rails will now allow management of application secrets in a secure way -built on top of the [sekrets](https://github.com/ahoward/sekrets) gem. +Rails will now allow management of application secrets in a secure way, +building on top of the [sekrets](https://github.com/ahoward/sekrets) gem. -Run `bin/rails secrets:setup` to setup a new encrypted secrets file. It will -generate a master key which needs to be stored outside of the repository, and it will -allow checking in the actual secrets in the revision control. +Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will +also generate a master key, which must be stored outside of the repository. The +secrets themselves can then be safely checked into the revision control system, +in an encrypted form. -The secrets will be decrypted in production using either the `RAILS_MASTER_KEY` -environment variable from a key file. +Secrets will be decrypted in production, using a key stored either in the +`RAILS_MASTER_KEY` environment variable, or in a key file. ### Parameterized mailers @@ -149,7 +151,7 @@ direct(:homepage) { "http://www.rubyonrails.org" } ``` The return value of the block must be a valid argument for the `url_for` -method. So, you can pass a valid string URL, Hash, array, an +method. So, you can pass a valid string URL, Hash, Array, an Active Model instance, or an Active Model class. ``` ruby -- cgit v1.2.3 From 8ee16836982b79a14198c75006672677f1f55947 Mon Sep 17 00:00:00 2001 From: Simon Dawson Date: Sun, 19 Mar 2017 08:34:47 +0000 Subject: Remove stray back-end from ActiveJob Basics guide The hyphenated form "back-end" only appears once in this guide; elsewhere, the un-hyphenated form "backend" is used consistently. --- guides/source/active_job_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index c65d1e6de5..b58ca61848 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -114,7 +114,7 @@ For enqueuing and executing jobs in production you need to set up a queuing back that is to say you need to decide for a 3rd-party queuing library that Rails should use. Rails itself only provides an in-process queuing system, which only keeps the jobs in RAM. If the process crashes or the machine is reset, then all outstanding jobs are lost with the -default async back-end. This may be fine for smaller apps or non-critical jobs, but most +default async backend. This may be fine for smaller apps or non-critical jobs, but most production apps will need to pick a persistent backend. ### Backends -- cgit v1.2.3 From 5c0d00072d1309dbc77bb5d97e42956bac3e8684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 20 Mar 2017 15:04:57 -0400 Subject: Update the maintenance policy [ci skip] --- guides/source/maintenance_policy.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/maintenance_policy.md b/guides/source/maintenance_policy.md index 7ced3eab1c..1d6a4edb5b 100644 --- a/guides/source/maintenance_policy.md +++ b/guides/source/maintenance_policy.md @@ -44,7 +44,7 @@ from. In special situations, where someone from the Core Team agrees to support more series, they are included in the list of supported series. -**Currently included series:** `5.0.Z`, `4.2.Z`. +**Currently included series:** `5.1.Z`. Security Issues --------------- @@ -59,7 +59,7 @@ be built from 1.2.2, and then added to the end of 1-2-stable. This means that security releases are easy to upgrade to if you're running the latest version of Rails. -**Currently included series:** `5.0.Z`, `4.2.Z`. +**Currently included series:** `5.1.Z`, `5.0.Z`. Severe Security Issues ---------------------- @@ -68,7 +68,7 @@ For severe security issues we will provide new versions as above, and also the last major release series will receive patches and new versions. The classification of the security issue is judged by the core team. -**Currently included series:** `5.0.Z`, `4.2.Z`. +**Currently included series:** `5.1.Z`, `5.0.Z`, `4.2.Z`. Unsupported Release Series -------------------------- -- cgit v1.2.3 From 17545b4d889149d8185c0a3a78030703d7e70c0e Mon Sep 17 00:00:00 2001 From: Erol Fornoles Date: Tue, 21 Mar 2017 09:21:51 +0800 Subject: Fix typo in Caching with Rails Guide [skip ci] --- guides/source/caching_with_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index af4ef6a58d..aa79f59e4f 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -574,7 +574,7 @@ Caching in Development ---------------------- It's common to want to test the caching strategy of your application -in developement mode. Rails provides the rake task `dev:cache` to +in development mode. Rails provides the rake task `dev:cache` to easily toggle caching on/off. ```bash -- cgit v1.2.3 From 3b51c8a591b0b79fa6d9f42f948b6b733dfae936 Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Tue, 21 Mar 2017 08:49:48 -0700 Subject: Update Configuring Rails Component guide example config.time_zone is no longer in included in config/application.rb. See 28dcadc0140dfdebe87d5e691fd709c0a9ae0bae. --- 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 a4f3882124..ae70b06996 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -32,7 +32,7 @@ Configuring Rails Components In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The configuration file `config/application.rb` and environment-specific configuration files (such as `config/environments/production.rb`) allow you to specify the various settings that you want to pass down to all of the components. -For example, the `config/application.rb` file includes this setting: +For example, you could add this setting to `config/application.rb` file: ```ruby config.time_zone = 'Central Time (US & Canada)' -- cgit v1.2.3 From 6c08d480f13d3332c878ca8a120a03fcd78f7ba2 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 22 Mar 2017 10:11:39 +1030 Subject: Start Rails 5.2 development --- guides/CHANGELOG.md | 7 +------ guides/bug_report_templates/action_controller_master.rb | 1 + guides/bug_report_templates/active_job_master.rb | 1 + guides/bug_report_templates/active_record_master.rb | 1 + guides/bug_report_templates/active_record_migrations_master.rb | 1 + guides/bug_report_templates/generic_master.rb | 1 + 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'guides') diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index 3a602efb3d..d8b122d264 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,6 +1 @@ -## Rails 5.1.0.beta1 (February 23, 2017) ## - -* No changes. - - -Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/guides/CHANGELOG.md) for previous changes. +Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/guides/CHANGELOG.md) for previous changes. diff --git a/guides/bug_report_templates/action_controller_master.rb b/guides/bug_report_templates/action_controller_master.rb index 486c7243ad..7644f6fe4a 100644 --- a/guides/bug_report_templates/action_controller_master.rb +++ b/guides/bug_report_templates/action_controller_master.rb @@ -8,6 +8,7 @@ end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails" + gem "arel", github: "rails/arel" end require "action_controller/railtie" diff --git a/guides/bug_report_templates/active_job_master.rb b/guides/bug_report_templates/active_job_master.rb index f61518713f..7591470440 100644 --- a/guides/bug_report_templates/active_job_master.rb +++ b/guides/bug_report_templates/active_job_master.rb @@ -8,6 +8,7 @@ end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails" + gem "arel", github: "rails/arel" end require "active_job" diff --git a/guides/bug_report_templates/active_record_master.rb b/guides/bug_report_templates/active_record_master.rb index 7265a671b0..8bbc1ef19e 100644 --- a/guides/bug_report_templates/active_record_master.rb +++ b/guides/bug_report_templates/active_record_master.rb @@ -8,6 +8,7 @@ end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails" + gem "arel", github: "rails/arel" gem "sqlite3" end diff --git a/guides/bug_report_templates/active_record_migrations_master.rb b/guides/bug_report_templates/active_record_migrations_master.rb index 13a375d1ba..84a4b71909 100644 --- a/guides/bug_report_templates/active_record_migrations_master.rb +++ b/guides/bug_report_templates/active_record_migrations_master.rb @@ -8,6 +8,7 @@ end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails" + gem "arel", github: "rails/arel" gem "sqlite3" end diff --git a/guides/bug_report_templates/generic_master.rb b/guides/bug_report_templates/generic_master.rb index d3a7ae4ac4..ed45726e92 100644 --- a/guides/bug_report_templates/generic_master.rb +++ b/guides/bug_report_templates/generic_master.rb @@ -8,6 +8,7 @@ end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails" + gem "arel", github: "rails/arel" end require "active_support" -- cgit v1.2.3 From afbbcf24d791362a65c7f29b739c73a5b09e3816 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 22 Mar 2017 10:11:43 +1030 Subject: Update bug report templates --- guides/bug_report_templates/action_controller_gem.rb | 2 +- guides/bug_report_templates/active_job_gem.rb | 2 +- guides/bug_report_templates/active_record_gem.rb | 2 +- guides/bug_report_templates/active_record_migrations_gem.rb | 2 +- guides/bug_report_templates/generic_gem.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'guides') diff --git a/guides/bug_report_templates/action_controller_gem.rb b/guides/bug_report_templates/action_controller_gem.rb index 85d698f81b..46fabca3e8 100644 --- a/guides/bug_report_templates/action_controller_gem.rb +++ b/guides/bug_report_templates/action_controller_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "rails", "5.0.1" + gem "rails", "5.1.0.rc1" end require "rack/test" diff --git a/guides/bug_report_templates/active_job_gem.rb b/guides/bug_report_templates/active_job_gem.rb index f715caec95..71fe356ea0 100644 --- a/guides/bug_report_templates/active_job_gem.rb +++ b/guides/bug_report_templates/active_job_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activejob", "5.0.1" + gem "activejob", "5.1.0.rc1" end require "minitest/autorun" diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb index 98edcb76b1..a685c257ea 100644 --- a/guides/bug_report_templates/active_record_gem.rb +++ b/guides/bug_report_templates/active_record_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activerecord", "5.0.1" + gem "activerecord", "5.1.0.rc1" gem "sqlite3" end diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index ece6ae4f12..b4e822dfe0 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activerecord", "5.0.1" + gem "activerecord", "5.1.0.rc1" gem "sqlite3" end diff --git a/guides/bug_report_templates/generic_gem.rb b/guides/bug_report_templates/generic_gem.rb index fa9f94eea0..e1b705bea4 100644 --- a/guides/bug_report_templates/generic_gem.rb +++ b/guides/bug_report_templates/generic_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activesupport", "5.0.1" + gem "activesupport", "5.1.0.rc1" end require "active_support/core_ext/object/blank" -- cgit v1.2.3 From 9e14f42a2ece637829eb8db307a105f321a0f77f Mon Sep 17 00:00:00 2001 From: brchristian Date: Thu, 23 Mar 2017 10:00:04 -0700 Subject: Additional explanation about cache implementations --- guides/source/caching_with_rails.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index aa79f59e4f..798fea9f30 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -387,6 +387,11 @@ store is not appropriate for large application deployments. However, it can work well for small, low traffic sites with only a couple of server processes, as well as development and test environments. +New Rails projects will be configured to use this implementation in the +development environment by default. (Note that, because processes will not share +cache data, if using `:memory_store` it will not be possible to manually read, +write or expire the cache via the Rails console.) + ### ActiveSupport::Cache::FileStore This cache store uses the file system to store entries. The path to the directory where the store files will be stored must be specified when initializing the cache. @@ -403,7 +408,8 @@ share a cache by using a shared file system, but that setup is not recommended. As the cache will grow until the disk is full, it is recommended to periodically clear out old entries. -This is the default cache store implementation. +This is the default cache store implementation (at `"#{root}/tmp/cache/"`) if +no explicit `config.cache_store` is supplied. ### ActiveSupport::Cache::MemCacheStore -- cgit v1.2.3 From aed7bb67485b1e4d4c7eeb40971ac4057d48999c Mon Sep 17 00:00:00 2001 From: Rachel Carvalho Date: Thu, 23 Mar 2017 16:21:11 -0400 Subject: update guide to reflect browser compatibility for HTTP verbs [ci skip] --- guides/source/security.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/security.md b/guides/source/security.md index a14134f8c1..7e27e6f37d 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -212,7 +212,7 @@ CSRF appears very rarely in CVE (Common Vulnerabilities and Exposures) - less th NOTE: _First, as is required by the W3C, use GET and POST appropriately. Secondly, a security token in non-GET requests will protect your application from CSRF._ -The HTTP protocol basically provides two main types of requests - GET and POST (and more, but they are not supported by most browsers). The World Wide Web Consortium (W3C) provides a checklist for choosing HTTP GET or POST: +The HTTP protocol basically provides two main types of requests - GET and POST (DELETE, PUT, and PATCH should be used like POST). The World Wide Web Consortium (W3C) provides a checklist for choosing HTTP GET or POST: **Use GET if:** @@ -224,7 +224,7 @@ The HTTP protocol basically provides two main types of requests - GET and POST ( * The interaction _changes the state_ of the resource in a way that the user would perceive (e.g., a subscription to a service), or * The user is _held accountable for the results_ of the interaction. -If your web application is RESTful, you might be used to additional HTTP verbs, such as PATCH, PUT or DELETE. Most of today's web browsers, however, do not support them - only GET and POST. Rails uses a hidden `_method` field to handle this barrier. +If your web application is RESTful, you might be used to additional HTTP verbs, such as PATCH, PUT or DELETE. Some legacy web browsers, however, do not support them - only GET and POST. Rails uses a hidden `_method` field to handle these cases. _POST requests can be sent automatically, too_. In this example, the link www.harmless.com is shown as the destination in the browser's status bar. But it has actually dynamically created a new form that sends a POST request. -- cgit v1.2.3 From 684de497a8c60c9cb367ff2e3657fb785c2a35ea Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Fri, 24 Mar 2017 18:14:01 +0530 Subject: Doc cleanup for caching guide [ci skip] (#28556) --- guides/source/caching_with_rails.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 798fea9f30..6cdce5c2f4 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -387,10 +387,10 @@ store is not appropriate for large application deployments. However, it can work well for small, low traffic sites with only a couple of server processes, as well as development and test environments. -New Rails projects will be configured to use this implementation in the -development environment by default. (Note that, because processes will not share -cache data, if using `:memory_store` it will not be possible to manually read, -write or expire the cache via the Rails console.) +New Rails projects are configured to use this implementation in development environment by default. + +NOTE: Since processes will not share cache data when using `:memory_store`, +it will not be possible to manually read, write or expire the cache via the Rails console. ### ActiveSupport::Cache::FileStore -- cgit v1.2.3 From c096262f614a0c307f89691e9b8e976b3be3f89f Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 25 Mar 2017 20:57:40 +0900 Subject: Rename local variable name `current_user` to `verified_user` [ci skip] Related #28570 --- guides/source/action_cable_overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index e929945dd0..50a28571b4 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -6,7 +6,7 @@ incorporate real-time features into your Rails application. After reading this guide, you will know: -* What Action Cable is and its integration on backend and frontend +* What Action Cable is and its integration on backend and frontend * How to setup Action Cable * How to setup channels * Deployment and Architecture setup for running Action Cable @@ -64,8 +64,8 @@ module ApplicationCable private def find_verified_user - if current_user = User.find_by(id: cookies.signed[:user_id]) - current_user + if verified_user = User.find_by(id: cookies.signed[:user_id]) + verified_user else reject_unauthorized_connection end -- cgit v1.2.3 From f116d36c93a316302239de9ef17bf1f19aef3b45 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 25 Mar 2017 11:27:28 -0400 Subject: Add WIP Rails 5.1 release notes to documents.yaml [ci skip] --- guides/source/documents.yaml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'guides') diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 2925fb4b58..5fccdcccec 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -193,6 +193,11 @@ name: Upgrading Ruby on Rails url: upgrading_ruby_on_rails.html description: This guide helps in upgrading applications to latest Ruby on Rails versions. + - + name: Ruby on Rails 5.1 Release Notes + url: 5_1_release_notes.html + description: Release notes for Rails 5.1. + work_in_progress: true - name: Ruby on Rails 5.0 Release Notes url: 5_0_release_notes.html -- cgit v1.2.3 From aaa9a5b5d80f168e71593a75b06de94ab6129bca Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 25 Mar 2017 11:45:46 -0400 Subject: Upgrade various Rails 5.0 references to 5.1 RC1 is out, `5-1-stable` has been created, figured it was time to start updating this stuff :) [ci skip] --- guides/source/_welcome.html.erb | 3 ++- guides/source/command_line.md | 8 ++++---- guides/source/debugging_rails_applications.md | 12 ++++++------ guides/source/getting_started.md | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'guides') diff --git a/guides/source/_welcome.html.erb b/guides/source/_welcome.html.erb index 5bd1ea4d22..8afec00018 100644 --- a/guides/source/_welcome.html.erb +++ b/guides/source/_welcome.html.erb @@ -10,12 +10,13 @@

<% else %>

- These are the new guides for Rails 5.0 based on <%= @version %>. + These are the new guides for Rails 5.1 based on <%= @version %>. These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.

<% end %>

The guides for earlier releases: +Rails 5.0, Rails 4.2, Rails 4.1, Rails 4.0, diff --git a/guides/source/command_line.md b/guides/source/command_line.md index c8d559745e..e28547e14f 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -63,7 +63,7 @@ With no further work, `rails server` will run our new shiny Rails app: $ cd commandsapp $ bin/rails server => Booting Puma -=> Rails 5.0.0 application starting in development on http://0.0.0.0:3000 +=> Rails 5.1.0 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.0.2 (ruby 2.3.0-p0), codename: Plethora of Penguin Pinatas @@ -294,7 +294,7 @@ If you wish to test out some code without changing any data, you can do that by ```bash $ bin/rails console --sandbox -Loading development environment in sandbox (Rails 5.0.0) +Loading development environment in sandbox (Rails 5.1.0) Any modifications you make will be rolled back on exit irb(main):001:0> ``` @@ -428,10 +428,10 @@ INFO: You can also use `bin/rails -T` to get the list of tasks. ```bash $ bin/rails about About your application's environment -Rails version 5.0.0 +Rails version 5.1.0 Ruby version 2.2.2 (x86_64-linux) RubyGems version 2.4.6 -Rack version 1.6 +Rack version 2.0.1 JavaScript Runtime Node.js (V8) Middleware Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, #, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, Rack::Head, Rack::ConditionalGet, Rack::ETag Application root /home/foobar/commandsapp diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 33dee6a868..58aab774b3 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -313,7 +313,7 @@ For example: ```bash => Booting Puma -=> Rails 5.0.0 application starting in development on http://0.0.0.0:3000 +=> Rails 5.1.0 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.4.0 (ruby 2.3.1-p112), codename: Owl Bowl Brawl @@ -445,11 +445,11 @@ then `backtrace` will supply the answer. --> #0 ArticlesController.index at /PathToProject/app/controllers/articles_controller.rb:8 #1 ActionController::BasicImplicitRender.send_action(method#String, *args#Array) - at /PathToGems/actionpack-5.0.0/lib/action_controller/metal/basic_implicit_render.rb:4 + at /PathToGems/actionpack-5.1.0/lib/action_controller/metal/basic_implicit_render.rb:4 #2 AbstractController::Base.process_action(action#NilClass, *args#Array) - at /PathToGems/actionpack-5.0.0/lib/abstract_controller/base.rb:181 + at /PathToGems/actionpack-5.1.0/lib/abstract_controller/base.rb:181 #3 ActionController::Rendering.process_action(action, *args) - at /PathToGems/actionpack-5.0.0/lib/action_controller/metal/rendering.rb:30 + at /PathToGems/actionpack-5.1.0/lib/action_controller/metal/rendering.rb:30 ... ``` @@ -461,7 +461,7 @@ context. ``` (byebug) frame 2 -[176, 185] in /PathToGems/actionpack-5.0.0/lib/abstract_controller/base.rb +[176, 185] in /PathToGems/actionpack-5.1.0/lib/abstract_controller/base.rb 176: # is the intended way to override action dispatching. 177: # 178: # Notice that the first argument is the method to be dispatched @@ -676,7 +676,7 @@ Ruby instruction to be executed -- in this case, Active Support's `week` method. ``` (byebug) step -[49, 58] in /PathToGems/activesupport-5.0.0/lib/active_support/core_ext/numeric/time.rb +[49, 58] in /PathToGems/activesupport-5.1.0/lib/active_support/core_ext/numeric/time.rb 49: 50: # Returns a Duration instance matching the number of weeks provided. 51: # diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 57b8472462..068114898d 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -127,7 +127,7 @@ run the following: $ rails --version ``` -If it says something like "Rails 5.0.0", you are ready to continue. +If it says something like "Rails 5.1.0", you are ready to continue. ### Creating the Blog Application -- cgit v1.2.3 From 430f1e02fafd30a08edfa2b1e8032eb7e0e729cc Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 25 Mar 2017 11:52:16 -0400 Subject: Update middleware list Taken from `bin/rails about` run on a v5.1.0.rc1 application. [ci skip] --- guides/source/command_line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/command_line.md b/guides/source/command_line.md index e28547e14f..3360496c08 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -433,7 +433,7 @@ Ruby version 2.2.2 (x86_64-linux) RubyGems version 2.4.6 Rack version 2.0.1 JavaScript Runtime Node.js (V8) -Middleware Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, #, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, Rack::Head, Rack::ConditionalGet, Rack::ETag +Middleware: Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, Rack::Head, Rack::ConditionalGet, Rack::ETag Application root /home/foobar/commandsapp Environment development Database adapter sqlite3 -- cgit v1.2.3 From b8c330cb69c1b4e4cdfe30872db2a36d119b9c1b Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 25 Mar 2017 12:17:37 -0400 Subject: Small grammar fix Add necessary commas. [ci skip] --- guides/source/contributing_to_ruby_on_rails.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index fe5437ae5d..9ffc86aa08 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -98,13 +98,13 @@ Anything you can do to make bug reports more succinct or easier to reproduce hel ### Testing Patches -You can also help out by examining pull requests that have been submitted to Ruby on Rails via GitHub. To apply someone's changes you need first to create a dedicated branch: +You can also help out by examining pull requests that have been submitted to Ruby on Rails via GitHub. In order to apply someone's changes, you need to first create a dedicated branch: ```bash $ git checkout -b testing_branch ``` -Then you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to a topic branch "orange" located at https://github.com/JohnSmith/rails. +Then, you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to a topic branch "orange" located at https://github.com/JohnSmith/rails. ```bash $ git remote add JohnSmith https://github.com/JohnSmith/rails.git -- cgit v1.2.3 From 3f27c9cbe97010bff0a6fa4d770f3ce3c3703b31 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 25 Mar 2017 12:18:29 -0400 Subject: Small grammar fix Add apostrophe. [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 9ffc86aa08..3b19b0dff1 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -15,7 +15,7 @@ After reading this guide, you will know: Ruby on Rails is not "someone else's framework." Over the years, hundreds of people have contributed to Ruby on Rails ranging from a single character to massive architectural changes or significant documentation - all with the goal of making Ruby on Rails better for everyone. Even if you don't feel up to writing code or documentation yet, there are a variety of other ways that you can contribute, from reporting issues to testing patches. -As mentioned in [Rails +As mentioned in [Rails' README](https://github.com/rails/rails/blob/master/README.md), everyone interacting in Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails [code of conduct](http://rubyonrails.org/conduct/). -------------------------------------------------------------------------------- -- cgit v1.2.3 From 2b3a3738b7a519f32f593f6e6b9c6ba89daa72ea Mon Sep 17 00:00:00 2001 From: Frederik Wille Date: Wed, 29 Mar 2017 15:46:10 +0200 Subject: add hint on after_action filters Adds a hint that ``after_action``-callbacks are not executed when an exception was raised in the rest of the request cycle. The ``before_action`` section mentions "If there are additional filters scheduled to run after that filter, they are also cancelled." but this is IMO not sufficient. --- guides/source/action_controller_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 69c4a00c5f..a43a69b7a3 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -719,7 +719,7 @@ Now, the `LoginsController`'s `new` and `create` actions will work as before wit In addition to "before" filters, you can also run filters after an action has been executed, or both before and after. -"after" filters are similar to "before" filters, but because the action has already been run they have access to the response data that's about to be sent to the client. Obviously, "after" filters cannot stop the action from running. +"after" filters are similar to "before" filters, but because the action has already been run they have access to the response data that's about to be sent to the client. Obviously, "after" filters cannot stop the action from running. Please note that "after" filters are executed only after a successful action but not when an exception was raised in the request cycle. "around" filters are responsible for running their associated actions by yielding, similar to how Rack middlewares work. -- cgit v1.2.3 From 40f226ae94a726ca8935062a8aac50af8cad1de9 Mon Sep 17 00:00:00 2001 From: Ryunosuke Sato Date: Thu, 30 Mar 2017 01:10:20 +0900 Subject: Fix link to rails-ujs https://github.com/rails/rails-ujs is merged into actionview in favor of https://github.com/rails/rails/pull/28098. [skip ci] --- guides/source/action_mailer_basics.md | 2 +- guides/source/security.md | 2 +- guides/source/working_with_javascript_in_rails.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index 9673571909..65146ee7da 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -550,7 +550,7 @@ url helper. <%= user_url(@user, host: 'example.com') %> ``` -NOTE: non-`GET` links require [rails-ujs](https://github.com/rails/rails-ujs) or +NOTE: non-`GET` links require [rails-ujs](https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts) or [jQuery UJS](https://github.com/rails/jquery-ujs), and won't work in mailer templates. They will result in normal `GET` requests. diff --git a/guides/source/security.md b/guides/source/security.md index 7e27e6f37d..c305350243 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -257,7 +257,7 @@ protect_from_forgery with: :exception This will automatically include a security token in all forms and Ajax requests generated by Rails. If the security token doesn't match what was expected, an exception will be thrown. -NOTE: By default, Rails includes an [unobtrusive scripting adapter](https://github.com/rails/rails-ujs), +NOTE: By default, Rails includes an [unobtrusive scripting adapter](https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts), which adds a header called `X-CSRF-Token` with the security token on every non-GET Ajax call. Without this header, non-GET Ajax requests won't be accepted by Rails. When using another library to make Ajax calls, it is necessary to add the security diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index e04b3e3581..cbaf9100f7 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -149,7 +149,7 @@ Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two parts: the JavaScript half and the Ruby half. Unless you have disabled the Asset Pipeline, -[rails-ujs](https://github.com/rails/rails-ujs/blob/master/src/rails-ujs.coffee) +[rails-ujs](https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs.coffee) provides the JavaScript half, and the regular Ruby view helpers add appropriate tags to your DOM. -- cgit v1.2.3 From f77a6be8d23f048ced4fac54f1f4caea5e0749d7 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 29 Mar 2017 16:14:06 -0400 Subject: Small grammar fix Add comma and change verb. [ci skip] --- guides/source/action_controller_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index a43a69b7a3..5d987264f5 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -719,7 +719,7 @@ Now, the `LoginsController`'s `new` and `create` actions will work as before wit In addition to "before" filters, you can also run filters after an action has been executed, or both before and after. -"after" filters are similar to "before" filters, but because the action has already been run they have access to the response data that's about to be sent to the client. Obviously, "after" filters cannot stop the action from running. Please note that "after" filters are executed only after a successful action but not when an exception was raised in the request cycle. +"after" filters are similar to "before" filters, but because the action has already been run they have access to the response data that's about to be sent to the client. Obviously, "after" filters cannot stop the action from running. Please note that "after" filters are executed only after a successful action, but not when an exception is raised in the request cycle. "around" filters are responsible for running their associated actions by yielding, similar to how Rack middlewares work. -- cgit v1.2.3 From b68aae003ad7456f6c365fa86d212fd1e5a46ff7 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Thu, 30 Mar 2017 15:57:32 -0400 Subject: Small grammar fix [ci skip] --- guides/source/routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/routing.md b/guides/source/routing.md index 86492a9332..53735ce82e 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -545,7 +545,7 @@ TIP: If you find yourself adding many extra actions to a resourceful route, it's Non-Resourceful Routes ---------------------- -In addition to resource routing, Rails has powerful support for routing arbitrary URLs to actions. Here, you don't get groups of routes automatically generated by resourceful routing. Instead, you set up each route within your application separately. +In addition to resource routing, Rails has powerful support for routing arbitrary URLs to actions. Here, you don't get groups of routes automatically generated by resourceful routing. Instead, you set up each route separately within your application. While you should usually use resourceful routing, there are still many places where the simpler routing is more appropriate. There's no need to try to shoehorn every last piece of your application into a resourceful framework if that's not a good fit. -- cgit v1.2.3 From 9aeba503c4bc321e4c5a14cd9c9fbf9fbcc60edb Mon Sep 17 00:00:00 2001 From: Ross Kaffenberger Date: Fri, 31 Mar 2017 18:11:15 -0400 Subject: Add default_scope note to AR guide [ci skip] Adds note to explain unexpected behavior described in issue #28561. Developers may be surprised that the internal representation of similar query conditions in Hash and Array formats in default_scope will yield different results for model initialization. Link: https://github.com/rails/rails/issues/28561 --- guides/source/active_record_querying.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 2902c5d677..26d01d4ede 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1381,8 +1381,9 @@ class Client < ApplicationRecord end ``` -NOTE: The `default_scope` is also applied while creating/building a record. -It is not applied while updating a record. E.g.: +NOTE: The `default_scope` is also applied while creating/building a record +when the scope arguments are given as a `Hash`. It is not applied while +updating a record. E.g.: ```ruby class Client < ApplicationRecord @@ -1393,6 +1394,17 @@ Client.new # => # Client.unscoped.new # => # ``` +Be aware that, when given in the `Array` format, `default_scope` query arguments +cannot be converted to a `Hash` for default attribute assignment. E.g.: + +```ruby +class Client < ApplicationRecord + default_scope { where("active = ?", true) } +end + +Client.new # => # +``` + ### Merging of scopes Just like `where` clauses scopes are merged using `AND` conditions. -- cgit v1.2.3 From b5c56090ee5f71134b85e3cdf7e3b89093649fac Mon Sep 17 00:00:00 2001 From: Ruy Diaz Date: Sat, 1 Apr 2017 21:35:20 -0700 Subject: Add anchor links to all headers To allow easy linking at all levels and not just from index --- guides/assets/stylesheets/main.css | 3 +++ guides/rails_guides/markdown.rb | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'guides') diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css index b56699a0d0..a1e4851833 100644 --- a/guides/assets/stylesheets/main.css +++ b/guides/assets/stylesheets/main.css @@ -294,6 +294,9 @@ a, a:link, a:visited { #mainCol a, #subCol a, #feature a {color: #980905;} #mainCol a code, #subCol a code, #feature a code {color: #980905;} +#mainCol a.anchorlink { text-decoration: none; } +#mainCol a.anchorlink:hover { text-decoration: underline; } + /* Navigation --------------------------------------- */ diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb index bf2cc82c7c..16aaa7d1eb 100644 --- a/guides/rails_guides/markdown.rb +++ b/guides/rails_guides/markdown.rb @@ -105,6 +105,10 @@ module RailsGuides node.inner_html = "#{node_index(hierarchy)} #{node.inner_html}" end end + + doc.css('h3, h4, h5, h6').each do |node| + node.inner_html = "#{node.inner_html}" + end end.to_html end end -- cgit v1.2.3 From f2e6f5fb3fec7c16467d3a776164551236eb93be Mon Sep 17 00:00:00 2001 From: Ruy Diaz Date: Tue, 4 Apr 2017 10:53:41 -0700 Subject: Downplay links in Guides headers [ci skip] --- guides/assets/stylesheets/main.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css index a1e4851833..d428da3b56 100644 --- a/guides/assets/stylesheets/main.css +++ b/guides/assets/stylesheets/main.css @@ -294,7 +294,10 @@ a, a:link, a:visited { #mainCol a, #subCol a, #feature a {color: #980905;} #mainCol a code, #subCol a code, #feature a code {color: #980905;} -#mainCol a.anchorlink { text-decoration: none; } +#mainCol a.anchorlink { + color: #333; + text-decoration: none; +} #mainCol a.anchorlink:hover { text-decoration: underline; } /* Navigation -- cgit v1.2.3 From 0a61a321c7135d1eb04e7ef8caab07a1ef486ff7 Mon Sep 17 00:00:00 2001 From: claudiob Date: Tue, 4 Apr 2017 12:09:17 -0700 Subject: Don't highlight code in anchorlink [ci skip] Minor fix to #28662 --- guides/assets/stylesheets/main.css | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'guides') diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css index d428da3b56..b27776745a 100644 --- a/guides/assets/stylesheets/main.css +++ b/guides/assets/stylesheets/main.css @@ -294,10 +294,8 @@ a, a:link, a:visited { #mainCol a, #subCol a, #feature a {color: #980905;} #mainCol a code, #subCol a code, #feature a code {color: #980905;} -#mainCol a.anchorlink { - color: #333; - text-decoration: none; -} +#mainCol a.anchorlink, #mainCol a.anchorlink code {color: #333;} +#mainCol a.anchorlink { text-decoration: none; } #mainCol a.anchorlink:hover { text-decoration: underline; } /* Navigation -- cgit v1.2.3 From 3820abd36d22ac133b4146c8d59c1dda847e4f91 Mon Sep 17 00:00:00 2001 From: Alessandro Dal Grande Date: Tue, 4 Apr 2017 16:21:08 -0700 Subject: Fix edge guides for Active Record callbacks --- guides/source/active_record_callbacks.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 77bd3c97e8..de0ef7c4e5 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -254,7 +254,11 @@ Halting Execution As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed. -The whole callback chain is wrapped in a transaction. If any _before_ callback method returns exactly `false` or raises an exception, the execution chain gets halted and a ROLLBACK is issued; _after_ callbacks can only accomplish that by raising an exception. +The whole callback chain is wrapped in a transaction. If any callback raises an exception, the execution chain gets halted and a ROLLBACK is issued. To intentionally stop a chain use: + +```ruby +throw :abort +``` WARNING. Any exception that is not `ActiveRecord::Rollback` or `ActiveRecord::RecordInvalid` will be re-raised by Rails after the callback chain is halted. Raising an exception other than `ActiveRecord::Rollback` or `ActiveRecord::RecordInvalid` may break code that does not expect methods like `save` and `update_attributes` (which normally try to return `true` or `false`) to raise an exception. -- cgit v1.2.3 From b4038ab37ac4e869632238071a3d6714a152a0a5 Mon Sep 17 00:00:00 2001 From: Kevin Reintjes Date: Mon, 27 Feb 2017 17:45:24 +0100 Subject: Correct Autoloading and STI guide (issue #26994) --- guides/source/autoloading_and_reloading_constants.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'guides') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 61657023e7..05743ee4ce 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -983,20 +983,19 @@ WHERE "polygons"."type" IN ("Rectangle") That is not a bug, the query includes all *known* descendants of `Rectangle`. A way to ensure this works correctly regardless of the order of execution is to -load the leaves of the tree by hand at the bottom of the file that defines the -root class: +manually load the direct subclasses at the bottom of the file that defines each +intermediate class: ```ruby -# app/models/polygon.rb -class Polygon < ApplicationRecord +# app/models/rectangle.rb +class Rectangle < Polygon end -require_dependency ‘square’ +require_dependency 'square' ``` -Only the leaves that are **at least grandchildren** need to be loaded this -way. Direct subclasses do not need to be preloaded. If the hierarchy is -deeper, intermediate classes will be autoloaded recursively from the bottom -because their constant will appear in the class definitions as superclass. +This needs to happen for every intermediate (non-root and non-leaf) class. The +root class does not scope the query by type, and therefore does not necessarily +have to know all its descendants. ### Autoloading and `require` -- cgit v1.2.3 From 0b4ff7eacfeb36fca86c597da7c3ace059f8517a Mon Sep 17 00:00:00 2001 From: claudiob Date: Fri, 7 Apr 2017 09:18:19 -0700 Subject: Fix Guides to include #23138 [ci skip] A long-standing bug has been fixed in Rails 5.1 by @pixeltrix See https://github.com/rails/rails/blame/5-1-stable/actionpack/CHANGELOG.md#L52-L64 This PR updates the guides accordingly. Before: before After: after --- guides/source/routing.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'guides') diff --git a/guides/source/routing.md b/guides/source/routing.md index 53735ce82e..545f53a8e0 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -152,6 +152,7 @@ This resourceful route: ```ruby resource :geocoder +resolve('Geocoder') { [:geocoder] } ``` creates six different routes in your application, all mapping to the `Geocoders` controller: @@ -175,14 +176,6 @@ A singular resourceful route generates these helpers: As with plural resources, the same helpers ending in `_url` will also include the host, port and path prefix. -WARNING: A [long-standing bug](https://github.com/rails/rails/issues/1769) prevents `form_for` from working automatically with singular resources. As a workaround, specify the URL for the form directly, like so: - -```ruby -form_for @geocoder, url: geocoder_path do |f| - -# snippet for brevity -``` - ### Controller Namespaces and Routing You may wish to organize groups of controllers under a namespace. Most commonly, you might group a number of administrative controllers under an `Admin::` namespace. You would place these controllers under the `app/controllers/admin` directory, and you can group them together in your router: -- cgit v1.2.3 From 6f71e508a1272170dc93a31c5fc677f7f802d9eb Mon Sep 17 00:00:00 2001 From: Mikhail Dieterle Date: Sat, 8 Apr 2017 14:11:36 +0300 Subject: [ci skip] Change ++ by markdown quotes --- guides/source/active_model_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index e26805d22c..b8f076a27b 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -469,7 +469,7 @@ In order to make this work, the model must have an accessor named `password_dige The `has_secure_password` will add the following validations on the `password` accessor: 1. Password should be present. -2. Password should be equal to its confirmation (provided +password_confirmation+ is passed along). +2. Password should be equal to its confirmation (provided `password_confirmation` is passed along). 3. The maximum length of a password is 72 (required by `bcrypt` on which ActiveModel::SecurePassword depends) #### Examples -- cgit v1.2.3 From 668f8691f1017042e238497d1a5b7b8bf1c43819 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sun, 9 Apr 2017 00:31:58 +0930 Subject: Remove mentions and instructions for docrails It's been retired; all contributions now come in via PRs. --- guides/source/api_documentation_guidelines.md | 4 ---- guides/source/contributing_to_ruby_on_rails.md | 16 ++-------------- 2 files changed, 2 insertions(+), 18 deletions(-) (limited to 'guides') diff --git a/guides/source/api_documentation_guidelines.md b/guides/source/api_documentation_guidelines.md index 34b9c0d2ca..3c61754982 100644 --- a/guides/source/api_documentation_guidelines.md +++ b/guides/source/api_documentation_guidelines.md @@ -333,10 +333,6 @@ As a contributor, it's important to think about whether this API is meant for en A class or module is marked with `:nodoc:` to indicate that all methods are internal API and should never be used directly. -If you come across an existing `:nodoc:` you should tread lightly. Consider asking someone from the core team or author of the code before removing it. This should almost always happen through a pull request instead of the docrails project. - -A `:nodoc:` should never be added simply because a method or class is missing documentation. There may be an instance where an internal public method wasn't given a `:nodoc:` by mistake, for example when switching a method from private to public visibility. When this happens it should be discussed over a PR on a case-by-case basis and never committed directly to docrails. - To summarize, the Rails team uses `:nodoc:` to mark publicly visible methods and classes for internal use; changes to the visibility of API should be considered carefully and discussed over a pull request first. Regarding the Rails Stack diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 3b19b0dff1..2e8228a698 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -132,24 +132,12 @@ learn about Ruby on Rails, and the API, which serves as a reference. You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing them up to date with the latest edge Rails. -You can either open a pull request to [Rails](https://github.com/rails/rails) or -ask the [Rails core team](http://rubyonrails.org/community/#core) for commit access on -docrails if you contribute regularly. -Please do not open pull requests in docrails, if you'd like to get feedback on your -change, ask for it in [Rails](https://github.com/rails/rails) instead. - -Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation. - -If you are unsure of the documentation changes, you can create an issue in the [Rails](https://github.com/rails/rails/issues) issues tracker on GitHub. +To do so, open a pull request to [Rails](https://github.com/rails/rails) on GitHub. 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: As explained earlier, ordinary code patches should have proper documentation coverage. Docrails is only used for isolated documentation improvements. - 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. -WARNING: Docrails has a very strict policy: no code can be touched whatsoever, no matter how trivial or small the change. Only RDoc and guides can be edited via docrails. Also, CHANGELOGs should never be edited in docrails. - Translating Rails Guides ------------------------ @@ -685,4 +673,4 @@ And then... think about your next contribution! Rails Contributors ------------------ -All contributions, either via master or docrails, get credit in [Rails Contributors](http://contributors.rubyonrails.org). +All contributions get credit in [Rails Contributors](http://contributors.rubyonrails.org). -- cgit v1.2.3 From 24eb450d7599bab1f5863e0578a21c65ca42a915 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sun, 9 Apr 2017 00:36:45 +0930 Subject: Drop the "Sanity Check" contributing step --- guides/source/contributing_to_ruby_on_rails.md | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'guides') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 2e8228a698..39f4272b3c 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -406,16 +406,6 @@ examples or multiple paragraphs. Otherwise, it's best to make a new paragraph. Some changes require the dependencies to be upgraded. In these cases make sure you run `bundle update` to get the right version of the dependency and commit the `Gemfile.lock` file within your changes. -### Sanity Check - -You should not be the only person who looks at the code before you submit it. -If you know someone else who uses Rails, try asking them if they'll check out -your work. If you don't know anyone else using Rails, try hopping into the IRC -room or posting about your idea to the rails-core mailing list. Doing this in -private before you push a patch out publicly is the "smoke test" for a patch: -if you can't convince one other developer of the beauty of your code, you’re -unlikely to convince the core team either. - ### Commit Your Changes When you're happy with the code on your computer, you need to commit the changes to Git: -- cgit v1.2.3 From f785ad786ae49dd6f7a2f1d77c44ea17008c6656 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 8 Apr 2017 17:10:42 -0400 Subject: Add scaffolding for different sections in 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 5d4885d55c..d796236807 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -223,41 +223,89 @@ Railties Please refer to the [Changelog][railties] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Action Pack ----------- Please refer to the [Changelog][action-pack] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Action View ------------- Please refer to the [Changelog][action-view] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Action Mailer ------------- Please refer to the [Changelog][action-mailer] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Active Record ------------- Please refer to the [Changelog][active-record] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Active Model ------------ Please refer to the [Changelog][active-model] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Active Job ----------- Please refer to the [Changelog][active-job] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Active Support -------------- Please refer to the [Changelog][active-support] for detailed changes. +### Removals + +### Deprecations + +### Notable changes + Credits ------- -- cgit v1.2.3 From 3b5a6dfb18f33c373a89760c60d741f34206f23b Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 8 Apr 2017 20:52:07 -0400 Subject: Add text to "Upgrading to Rails 5.1" [ci skip] --- guides/source/5_1_release_notes.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index d796236807..e995c50297 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -24,7 +24,14 @@ repository on GitHub. Upgrading to Rails 5.1 ---------------------- -ToDo +If you're upgrading an existing application, it's a great idea to have good test +coverage before going in. You should also first upgrade to Rails 5.0 in case you +haven't and make sure your application still runs as expected before attempting +an update to Rails 5.1. A list of things to watch out for when upgrading is +available in the +[Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-5-0-to-rails-5-1) +guide. + Major Features -------------- -- cgit v1.2.3 From cad58fb413947142cc501d55ec6ab7099b3ff706 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Mon, 27 Mar 2017 03:55:20 +0530 Subject: Started adding release notes for Rails 5.1 [ci skip] --- guides/source/5_1_release_notes.md | 94 +++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 22 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index e995c50297..cf6158b6fa 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -228,90 +228,140 @@ can generate form tags based on URLs, scopes or models. Railties -------- +### Removals + +### Deprecations + +### Notable Changes + Please refer to the [Changelog][railties] for detailed changes. +Action Cable +----------- + ### Removals ### Deprecations -### Notable changes +### Notable Changes + +* Added support for `channel_prefix` to Redis and evented Redis adapters + in `cable.yml` to avoid name collisions when using the same Redis server + with multiple applications. + ([Pull Request](https://github.com/rails/rails/pull/27425)) + +Please refer to the [Changelog][action-cable] for detailed changes. Action Pack ----------- -Please refer to the [Changelog][action-pack] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +Please refer to the [Changelog][action-pack] for detailed changes. Action View ------------- -Please refer to the [Changelog][action-view] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +Please refer to the [Changelog][action-view] for detailed changes. Action Mailer ------------- -Please refer to the [Changelog][action-mailer] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +* Allowed setting custom content type when attachments are included + and body is set inline. + ([Pull Request](https://github.com/rails/rails/pull/27227)) + +* Allowed passing lambdas as values to the `default` method. + ([Commit](https://github.com/rails/rails/commit/1cec84ad2ddd843484ed40b1eb7492063ce71baf)) + +* Added support for parameterized invocation of mailers to share before filters and defaults + between different mailer actions. + ([Commit](https://github.com/rails/rails/commit/1cec84ad2ddd843484ed40b1eb7492063ce71baf)) + +* Passed the incoming arguments to the mailer action to `process.action_mailer` event under + an `args` key. + ([Pull Request](https://github.com/rails/rails/pull/27900)) + +Please refer to the [Changelog][action-mailer] for detailed changes. Active Record ------------- -Please refer to the [Changelog][active-record] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +* Skipped comments in the output of `mysqldump` command by default. + ([Pull Request](https://github.com/rails/rails/pull/23301)) + +* Fixed `ActiveRecord::Relation#count` to use Ruby's `Enumerable#count` for counting + records when a block is passed as argument instead of silently ignoring the + passed block. + ([Pull Request](https://github.com/rails/rails/pull/24203)) + +* Pass `"-v ON_ERROR_STOP=1"` flag with `psql` command to not suppress SQL errors. + ([Pull Request](https://github.com/rails/rails/pull/24773)) + +Please refer to the [Changelog][active-record] for detailed changes. Active Model ------------ -Please refer to the [Changelog][active-model] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +Please refer to the [Changelog][active-model] for detailed changes. Active Job ----------- -Please refer to the [Changelog][active-job] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +Please refer to the [Changelog][active-job] for detailed changes. Active Support -------------- -Please refer to the [Changelog][active-support] for detailed changes. - ### Removals ### Deprecations -### Notable changes +### Notable Changes + +* Added `Module#delegate_missing_to` to delegate method calls not + defined for the current object to a proxy object. + ([Pull Request](https://github.com/rails/rails/pull/23930)) + +* Added `Date#all_day` which returns a range representing the whole day + of the current date & time. + ([Pull Request](https://github.com/rails/rails/pull/24930)) + +Please refer to the [Changelog][active-support] for detailed changes. Credits ------- -- cgit v1.2.3 From a1d16751064afdf9f66756e3b87c6c59246907bf Mon Sep 17 00:00:00 2001 From: vishalzambre Date: Thu, 6 Apr 2017 13:02:52 +0530 Subject: [ci skip] documented issue related before_destroy Updated text --- guides/source/active_record_callbacks.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 77bd3c97e8..817c7cc835 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -117,6 +117,8 @@ Here is a list with all the available Active Record callbacks, listed in the sam WARNING. `after_save` runs both on create and update, but always _after_ the more specific callbacks `after_create` and `after_update`, no matter the order in which the macro calls were executed. +NOTE: `before_destroy` callback should be placed before `dependent: :destroy` associations (or use the `prepend: true` option), to ensure they execute before the records are deleted by `dependent: :destroy`. + ### `after_initialize` and `after_find` The `after_initialize` callback will be called whenever an Active Record object is instantiated, either by directly using `new` or when a record is loaded from the database. It can be useful to avoid the need to directly override your Active Record `initialize` method. -- cgit v1.2.3 From 8801108c0f12827832a0082e17d2c087815fd99f Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 10 Apr 2017 10:44:18 -0400 Subject: Pluralize callback Users could have more than one `before_destroy` callback in their models. [ci skip] --- guides/source/active_record_callbacks.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 1a2c967643..b1705855d0 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -117,7 +117,9 @@ Here is a list with all the available Active Record callbacks, listed in the sam WARNING. `after_save` runs both on create and update, but always _after_ the more specific callbacks `after_create` and `after_update`, no matter the order in which the macro calls were executed. -NOTE: `before_destroy` callback should be placed before `dependent: :destroy` associations (or use the `prepend: true` option), to ensure they execute before the records are deleted by `dependent: :destroy`. +NOTE: `before_destroy` callbacks should be placed before `dependent: :destroy` +associations (or use the `prepend: true` option), to ensure they execute before +the records are deleted by `dependent: :destroy`. ### `after_initialize` and `after_find` -- cgit v1.2.3 From 374dca2d66d474ba3434bd67e9a20e4388b2a83e Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 10 Apr 2017 11:04:38 -0400 Subject: Small grammar fixes [ci skip] --- guides/source/rails_on_rack.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 340933c7ee..ed9c4bb72a 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -22,7 +22,9 @@ Rack provides a minimal, modular and adaptable interface for developing web appl * [Rack API Documentation](http://rack.github.io/) -Explaining Rack is not really in the scope of this guide. In case you are not familiar with Rack's basics, you should check out the [Resources](#resources) section below. +Explaining how Rack works is not really in the scope of this guide. In case you +are not familiar with Rack's basics, you should check out the [Resources](#resources) +section below. Rails on Rack ------------- @@ -74,7 +76,7 @@ And start the server: $ rackup config.ru ``` -To find out more about different `rackup` options: +To find out more about different `rackup` options, you can run: ```bash $ rackup --help @@ -89,7 +91,8 @@ Action Dispatcher Middleware Stack Many of Action Dispatcher's internal components are implemented as Rack middlewares. `Rails::Application` uses `ActionDispatch::MiddlewareStack` to combine various internal and external middlewares to form a complete Rails Rack application. -NOTE: `ActionDispatch::MiddlewareStack` is Rails equivalent of `Rack::Builder`, but built for better flexibility and more features to meet Rails' requirements. +NOTE: `ActionDispatch::MiddlewareStack` is Rails' equivalent of `Rack::Builder`, +but is built for better flexibility and more features to meet Rails' requirements. ### Inspecting Middleware Stack -- cgit v1.2.3 From c134a17b3d740ab1578cdd8da8aba3909910feb2 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 10 Apr 2017 11:05:05 -0400 Subject: Remove link to rack.github.io We mention the "resources" section of the guide in the next paragraph, and the link is listed there. IMHO we shouldn't list it twice. [ci skip] --- guides/source/rails_on_rack.md | 2 -- 1 file changed, 2 deletions(-) (limited to 'guides') diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index ed9c4bb72a..f25b185fb5 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -20,8 +20,6 @@ Introduction to Rack Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. -* [Rack API Documentation](http://rack.github.io/) - Explaining how Rack works is not really in the scope of this guide. In case you are not familiar with Rack's basics, you should check out the [Resources](#resources) section below. -- cgit v1.2.3 From 8ca42638bc3115e5161b084a668e253dee94fd24 Mon Sep 17 00:00:00 2001 From: Julian Nadeau Date: Mon, 13 Mar 2017 17:37:54 -0400 Subject: Add Documentation for Active Support On Load Hooks --- guides/source/engines.md | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) (limited to 'guides') diff --git a/guides/source/engines.md b/guides/source/engines.md index 180a786237..c7aedd2987 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -14,6 +14,7 @@ After reading this guide, you will know: * How to build features for the engine. * How to hook the engine into an application. * How to override engine functionality in the application. +* Avoid loading Rails frameworks with Load and Configuration Hooks -------------------------------------------------------------------------------- @@ -1410,3 +1411,114 @@ module MyEngine end end ``` + +Active Support On Load Hooks +---------------------------- + +Active Support is the Ruby on Rails component responsible for providing Ruby language extensions, utilities, and other transversal utilities. + +Rails code can often be referenced on load of an application. Rails is responsible for the load order of these frameworks, so when you load frameworks, such as `ActiveRecord::Base`, prematurely you are violating an implicit contract your application has with Rails. Moreover, by loading code such as `ActiveRecord::Base` on boot of your application you are loading entire frameworks which may slow down your boot time and could cause conflicts with load order and boot of your application. + +On Load hooks are the API that allow you to hook into this initialization process without violating the load contract with Rails. This will also mitigate boot performance degradation and avoid conflicts. + +## What are `on_load` hooks? + +Since Ruby is a dynamic language, some code will cause different Rails frameworks to load. Take this snippet for instance: + +```ruby +ActiveRecord::Base.include(MyActiveRecordHelper) +``` + +This snippet means that when this file is loaded, it will encounter `ActiveRecord::Base`. This encounter causes Ruby to look for the definition of that constant and will require it. This causes the entire Active Record framework to be loaded on boot. + +`ActiveSupport.on_load` is a mechanism that can be used to defer the loading of code until it is actually needed. The snippet above can be changed to: + +```ruby +ActiveSupport.on_load(:active_record) { include MyActiveRecordHelper } +``` + +This new snippet will only include `MyActiveRecordHelper` when `ActiveRecord::Base` is loaded. + +## How does it work? + +In the Rails framework these hooks are called when a specific library is loaded. For example, when `ActionController::Base` is loaded, the `:action_controller_base` hook is called. This means that all `ActiveSupport.on_load` calls with `:action_controller_base` hooks will be called in the context of `ActionController::Base` (that means `self` will be an `ActionController::Base`). + +## Modifying code to use `on_load` hooks + +Modifying code is generally straightforward. If you have a line of code that refers to a Rails framework such as `ActiveRecord::Base` you can wrap that code in an `on_load` hook. + +### Example 1 + +```ruby +ActiveRecord::Base.include(MyActiveRecordHelper) +``` + +becomes + +```ruby +ActiveSupport.on_load(:active_record) { include MyActiveRecordHelper } # self refers to ActiveRecord::Base here, so we can simply #include +``` + +### Example 2 + +```ruby +ActionController::Base.prepend(MyActionControllerHelper) +``` + +becomes + +```ruby +ActiveSupport.on_load(:action_controller_base) { prepend MyActionControllerHelper } # self refers to ActionController::Base here, so we can simply #prepend +``` + +### Example 3 + +```ruby +ActiveRecord::Base.include_root_in_json = true +``` + +becomes + +```ruby +ActiveSupport.on_load(:active_record) { self.include_root_in_json = true } # self refers to ActiveRecord::Base here +``` + +## Available Hooks + +These are the hooks you can use in your own code. + +To hook into the initialization process of one of the following classes use the available hook. + +| Class | Available Hooks | +| --------------------------------- | ------------------------------------ | +| `ActionCable` | `action_cable` | +| `ActionController::API` | `action_controller_api` | +| `ActionController::API` | `action_controller` | +| `ActionController::Base` | `action_controller_base` | +| `ActionController::Base` | `action_controller` | +| `ActionController::TestCase` | `action_controller_test_case` | +| `ActionDispatch::IntegrationTest` | `action_dispatch_integration_test` | +| `ActionMailer::Base` | `action_mailer` | +| `ActionMailer::TestCase` | `action_mailer_test_case` | +| `ActionView::Base` | `action_view` | +| `ActionView::TestCase` | `action_view_test_case` | +| `ActiveJob::Base` | `active_job` | +| `ActiveJob::TestCase` | `active_job_test_case` | +| `ActiveRecord::Base` | `active_record` | +| `ActiveSupport::TestCase` | `active_support_test_case` | +| `i18n` | `i18n` | + +## Configuration hooks + +These are the available configuration hooks. They do not hook into any particular framework, instead they run in context of the entire application. + +| Hook | Use Case | +| ---------------------- | ------------------------------------------------------------------------------------- | +| `before_configuration` | First configurable block to run. Called before any initializers are run. | +| `before_initialize` | Second configurable block to run. Called before frameworks initialize. | +| `before_eager_load` | Third configurable block to run. Does not run if `config.cache_classes` set to false. | +| `after_initialize` | Last configurable block to run. Called after frameworks initialize. | + +### Example + +`config.before_configuration { puts 'I am called before any initializers' }` -- cgit v1.2.3 From 04b9d6829723b5c6c7854e9c992f63aada0d72bb Mon Sep 17 00:00:00 2001 From: Dzianis Dashkevich Date: Tue, 11 Apr 2017 18:50:05 +0300 Subject: Update routing doc on the `get` `to:` option [ci skip] --- guides/source/routing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/routing.md b/guides/source/routing.md index 545f53a8e0..f7dbbc510e 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -142,10 +142,10 @@ Sometimes, you have a resource that clients always look up without referencing a get 'profile', to: 'users#show' ``` -Passing a `String` to `get` will expect a `controller#action` format, while passing a `Symbol` will map directly to an action but you must also specify the `controller:` to use: +Passing a `String` to `to:` will expect a `controller#action` format. When using a `Symbol`, the `to:` option should be replaced with `action:`. When using a `String` without a `#`, the `to:` option should be replaced with `controller:`: ```ruby -get 'profile', to: :show, controller: 'users' +get 'profile', action: :show, controller: 'users' ``` This resourceful route: -- cgit v1.2.3 From d4692c92c306184a5f96fff4b38f52e1fc3ee395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 11 Apr 2017 18:48:53 -0400 Subject: :scissors: [ci skip] --- guides/source/engines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/engines.md b/guides/source/engines.md index c7aedd2987..2276f348a1 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -1417,7 +1417,7 @@ Active Support On Load Hooks Active Support is the Ruby on Rails component responsible for providing Ruby language extensions, utilities, and other transversal utilities. -Rails code can often be referenced on load of an application. Rails is responsible for the load order of these frameworks, so when you load frameworks, such as `ActiveRecord::Base`, prematurely you are violating an implicit contract your application has with Rails. Moreover, by loading code such as `ActiveRecord::Base` on boot of your application you are loading entire frameworks which may slow down your boot time and could cause conflicts with load order and boot of your application. +Rails code can often be referenced on load of an application. Rails is responsible for the load order of these frameworks, so when you load frameworks, such as `ActiveRecord::Base`, prematurely you are violating an implicit contract your application has with Rails. Moreover, by loading code such as `ActiveRecord::Base` on boot of your application you are loading entire frameworks which may slow down your boot time and could cause conflicts with load order and boot of your application. On Load hooks are the API that allow you to hook into this initialization process without violating the load contract with Rails. This will also mitigate boot performance degradation and avoid conflicts. -- cgit v1.2.3 From 066e5d62d5e83830040083b5f34c9da8bed0ba4f Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sat, 15 Apr 2017 14:22:01 -0400 Subject: Revert parts of cad58fb Changelog links at the top of the components, and lowercased the 'c' in notable changes. Personally, the styling isn't super important to me, but it's what we always done in previous guides, so I figured it's better to keep with what we've always done. [ci skip] --- guides/source/5_1_release_notes.md | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index cf6158b6fa..43b5a0fdaf 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -228,60 +228,62 @@ can generate form tags based on URLs, scopes or models. Railties -------- +Please refer to the [Changelog][railties] for detailed changes. + ### Removals ### Deprecations -### Notable Changes - -Please refer to the [Changelog][railties] for detailed changes. +### Notable changes Action Cable ----------- +Please refer to the [Changelog][action-cable] for detailed changes. + ### Removals ### Deprecations -### Notable Changes +### Notable changes * Added support for `channel_prefix` to Redis and evented Redis adapters in `cable.yml` to avoid name collisions when using the same Redis server with multiple applications. ([Pull Request](https://github.com/rails/rails/pull/27425)) -Please refer to the [Changelog][action-cable] for detailed changes. - Action Pack ----------- +Please refer to the [Changelog][action-pack] for detailed changes. + ### Removals ### Deprecations -### Notable Changes - -Please refer to the [Changelog][action-pack] for detailed changes. +### Notable changes Action View ------------- +Please refer to the [Changelog][action-view] for detailed changes. + ### Removals ### Deprecations -### Notable Changes - -Please refer to the [Changelog][action-view] for detailed changes. +### Notable changes Action Mailer ------------- +Please refer to the [Changelog][action-mailer] for detailed changes. + ### Removals ### Deprecations -### Notable Changes +### Notable changes * Allowed setting custom content type when attachments are included and body is set inline. @@ -298,16 +300,16 @@ Action Mailer an `args` key. ([Pull Request](https://github.com/rails/rails/pull/27900)) -Please refer to the [Changelog][action-mailer] for detailed changes. - Active Record ------------- +Please refer to the [Changelog][active-record] for detailed changes. + ### Removals ### Deprecations -### Notable Changes +### Notable changes * Skipped comments in the output of `mysqldump` command by default. ([Pull Request](https://github.com/rails/rails/pull/23301)) @@ -320,38 +322,38 @@ Active Record * Pass `"-v ON_ERROR_STOP=1"` flag with `psql` command to not suppress SQL errors. ([Pull Request](https://github.com/rails/rails/pull/24773)) -Please refer to the [Changelog][active-record] for detailed changes. - Active Model ------------ +Please refer to the [Changelog][active-model] for detailed changes. + ### Removals ### Deprecations -### Notable Changes - -Please refer to the [Changelog][active-model] for detailed changes. +### Notable changes Active Job ----------- +Please refer to the [Changelog][active-job] for detailed changes. + ### Removals ### Deprecations -### Notable Changes - -Please refer to the [Changelog][active-job] for detailed changes. +### Notable changes Active Support -------------- +Please refer to the [Changelog][active-support] for detailed changes. + ### Removals ### Deprecations -### Notable Changes +### Notable changes * Added `Module#delegate_missing_to` to delegate method calls not defined for the current object to a proxy object. @@ -361,8 +363,6 @@ Active Support of the current date & time. ([Pull Request](https://github.com/rails/rails/pull/24930)) -Please refer to the [Changelog][active-support] for detailed changes. - Credits ------- -- cgit v1.2.3 From 908afa7d18fe54c7b7b6d4fcd48eaeb29362a432 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 16 Apr 2017 22:24:38 -0400 Subject: Small grammar fixes [ci skip] --- guides/source/working_with_javascript_in_rails.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 cbaf9100f7..dacd7b71e8 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -338,7 +338,7 @@ this: end ``` -Notice the format.js in the `respond_to` block; that allows the controller to +Notice the `format.js` in the `respond_to` block: that allows the controller to respond to your Ajax request. You then have a corresponding `app/views/users/create.js.erb` view file that generates the actual JavaScript code that will be sent and executed on the client side. @@ -355,7 +355,7 @@ which uses Ajax to speed up page rendering in most applications. ### How Turbolinks Works -Turbolinks attaches a click handler to all `` on the page. If your browser +Turbolinks attaches a click handler to all `` tags on the page. If your browser supports [PushState](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState%28%29_method), Turbolinks will make an Ajax request for the page, parse the response, and -- cgit v1.2.3 From bfa1ece75061e04d7abb79bbdd2a7581b7ce2b94 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 16 Apr 2017 22:25:23 -0400 Subject: Small grammar fix [ci skip] --- guides/source/working_with_javascript_in_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index dacd7b71e8..2a6a87c232 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -385,7 +385,7 @@ $(document).ready -> ``` However, because Turbolinks overrides the normal page loading process, the -event that this relies on will not be fired. If you have code that looks like +event that this relies upon will not be fired. If you have code that looks like this, you must change your code to do this instead: ```coffeescript -- cgit v1.2.3 From 767f29e181bdbbec2f96bb09822924eea18c2e9f Mon Sep 17 00:00:00 2001 From: Eric Henziger Date: Mon, 17 Apr 2017 12:01:34 +0200 Subject: Add missing word 'to' [ci skip] While the original sentence is easy to understand, adding the 'to' is imho a bit more correct. Sources: * https://ell.stackexchange.com/q/16964 * https://www.usingenglish.com/forum/threads/127099-It-is-referred-as-or-It-is-referred-to-as --- guides/source/generators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/generators.md b/guides/source/generators.md index d0b6cef3fd..a554e08204 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -426,7 +426,7 @@ Fallbacks allow your generators to have a single responsibility, increasing code Application Templates --------------------- -Now that you've seen how generators can be used _inside_ an application, did you know they can also be used to _generate_ applications too? This kind of generator is referred as a "template". This is a brief overview of the Templates API. For detailed documentation see the [Rails Application Templates guide](rails_application_templates.html). +Now that you've seen how generators can be used _inside_ an application, did you know they can also be used to _generate_ applications too? This kind of generator is referred to as a "template". This is a brief overview of the Templates API. For detailed documentation see the [Rails Application Templates guide](rails_application_templates.html). ```ruby gem "rspec-rails", group: "test" -- cgit v1.2.3 From 0963aab728ab854bb6e45889cd45054b25a0cd4b Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 17 Apr 2017 21:53:06 -0400 Subject: Small docs fix Add missing word "programming", to clarify what type of language Ruby is ;) [ci skip] --- 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 068114898d..18331bb73b 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -46,7 +46,7 @@ development with Rails. What is Rails? -------------- -Rails is a web application development framework written in the Ruby language. +Rails is a web application development framework written in the Ruby programming language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. -- cgit v1.2.3 From 2b82e96597d4d9a6054bdeea86e51477565ac449 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 19 Apr 2017 08:02:32 +0900 Subject: Remove datetime fields from helper list [ci skip] The `datetime_field` is an alias of the `datetime_local_field`, there is no helper to generate datetime fields. Ref: #25469 --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 0508b0fb38..ba6e158ba1 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -164,7 +164,7 @@ make it easier for users to click the inputs. Other form controls worth mentioning are textareas, password fields, hidden fields, search fields, telephone fields, date fields, time fields, -color fields, datetime fields, datetime-local fields, month fields, week fields, +color fields, datetime-local fields, month fields, week fields, URL fields, email fields, number fields and range fields: ```erb -- cgit v1.2.3 From e2648c42abe7466e2c982db6c5fd4565a0555562 Mon Sep 17 00:00:00 2001 From: vishalzambre Date: Wed, 19 Apr 2017 11:31:00 +0530 Subject: [ci skip] Changed plain text to NOTE. --- guides/source/active_record_migrations.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md index 6e7e29ed60..75e1096426 100644 --- a/guides/source/active_record_migrations.md +++ b/guides/source/active_record_migrations.md @@ -972,11 +972,11 @@ on. Because this is database-independent, it could be loaded into any database that Active Record supports. This could be very useful if you were to distribute an application that is able to run against multiple databases. -There is however a trade-off: `db/schema.rb` cannot express database specific -items such as triggers, stored procedures or check constraints. While in a -migration you can execute custom SQL statements, the schema dumper cannot -reconstitute those statements from the database. If you are using features like -this, then you should set the schema format to `:sql`. +NOTE: `db/schema.rb` cannot express database specific items such as triggers, +sequences, stored procedures or check constraints, etc. While in a migration you +can execute custom SQL statements, the schema dumper cannot reconstitute those +statements from the database. If you are using features like this, then you +should set the schema format to `:sql`. Instead of using Active Record's schema dumper, the database's structure will be dumped using a tool specific to the database (via the `db:structure:dump` -- cgit v1.2.3 From 54fa07f2c87a7aad9a17539e409497e46d2607cd Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 19 Apr 2017 15:40:25 -0400 Subject: Reword sentence Sentence had some awkward grammar and was kind of confusing, tried to make it easier to understand what it was trying to say :) [ci skip] --- guides/source/active_record_migrations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md index 75e1096426..7fdb5901f3 100644 --- a/guides/source/active_record_migrations.md +++ b/guides/source/active_record_migrations.md @@ -973,9 +973,9 @@ that Active Record supports. This could be very useful if you were to distribute an application that is able to run against multiple databases. NOTE: `db/schema.rb` cannot express database specific items such as triggers, -sequences, stored procedures or check constraints, etc. While in a migration you -can execute custom SQL statements, the schema dumper cannot reconstitute those -statements from the database. If you are using features like this, then you +sequences, stored procedures or check constraints, etc. Please note that while +custom SQL statements can be run in migrations, these statements cannot be reconstituted +by the schema dumper. If you are using features like this, then you should set the schema format to `:sql`. Instead of using Active Record's schema dumper, the database's structure will -- cgit v1.2.3 From 0871e5e5c1e6151a7ed3bdf7b22209ac11532b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 19 Apr 2017 20:02:03 -0400 Subject: Fix all style guides violations Closes #28382 Closes #28651 --- guides/Rakefile | 6 +++--- guides/rails_guides/markdown.rb | 2 +- guides/rails_guides/markdown/renderer.rb | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'guides') diff --git a/guides/Rakefile b/guides/Rakefile index 0a591558e1..3a6f10040f 100644 --- a/guides/Rakefile +++ b/guides/Rakefile @@ -17,13 +17,13 @@ namespace :guides do namespace :generate do desc "Generate HTML guides" - task :html => :encoding do + task html: :encoding do ENV["WARNINGS"] = "1" # authors can't disable this ruby "rails_guides.rb" end desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211" - task :kindle => :encoding do + task kindle: :encoding do require "kindlerb" unless Kindlerb.kindlegen_available? abort "Please run `setupkindlerb` to install kindlegen" @@ -38,7 +38,7 @@ namespace :guides do # Validate guides ------------------------------------------------------------------------- desc 'Validate guides, use ONLY=foo to process just "foo.html"' - task :validate => :encoding do + task validate: :encoding do ruby "w3c_validator.rb" end diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb index 16aaa7d1eb..02d58601c4 100644 --- a/guides/rails_guides/markdown.rb +++ b/guides/rails_guides/markdown.rb @@ -106,7 +106,7 @@ module RailsGuides end end - doc.css('h3, h4, h5, h6').each do |node| + doc.css("h3, h4, h5, h6").each do |node| node.inner_html = "#{node.inner_html}" end end.to_html diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb index 20cbd568c9..9d43c10be6 100644 --- a/guides/rails_guides/markdown/renderer.rb +++ b/guides/rails_guides/markdown/renderer.rb @@ -94,15 +94,15 @@ HTML tree = version || edge root = file_path[%r{(.+)/}, 1] - path = case root - when "abstract_controller", "action_controller", "action_dispatch" - "actionpack/lib/#{file_path}" - when /\A(action|active)_/ - "#{root.sub("_", "")}/lib/#{file_path}" - else - file_path - end - + path = \ + case root + when "abstract_controller", "action_controller", "action_dispatch" + "actionpack/lib/#{file_path}" + when /\A(action|active)_/ + "#{root.sub("_", "")}/lib/#{file_path}" + else + file_path + end "https://github.com/rails/rails/tree/#{tree}/#{path}" end -- cgit v1.2.3 From 0541a0d5481043a9c78371446389794944daf3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 21 Apr 2017 16:40:03 -0400 Subject: Add note about #26929 in the upgrade guide This is a small breaking change that we chose to make in 5.1 since the fix can be done with a search and replace tool. --- guides/source/upgrading_ruby_on_rails.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'guides') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 3afc0e5309..ebfdc78dfc 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -84,6 +84,23 @@ Also, if you have pretty old YAML documents containing dumps of such objects, you may need to load and dump them again to make sure that they reference the right constant and that loading them won't break in the future. +### `config.secrets` now load with all keys as symbols + +If you application stores nested configuration in `secrets.yml` now all keys are being +laded as symbols so access using strings should be changed. + +From: + +```ruby +Rails.appplication.config.secrets[:smtp_settings]["address"] +``` + +To: + +```ruby +Rails.application.config.secrets[:smtp_settings][:address] +``` + Upgrading from Rails 4.2 to Rails 5.0 ------------------------------------- -- cgit v1.2.3 From 93897d79edfb5b546bf544a27b92f66882ca1b88 Mon Sep 17 00:00:00 2001 From: Shanthi Pendleton Date: Sun, 23 Apr 2017 13:28:38 +0100 Subject: [ci_skip] Fix typo in Rails 5.1 upgrade notes --- 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 ebfdc78dfc..3284a6c77e 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -87,7 +87,7 @@ the right constant and that loading them won't break in the future. ### `config.secrets` now load with all keys as symbols If you application stores nested configuration in `secrets.yml` now all keys are being -laded as symbols so access using strings should be changed. +loaded as symbols so access using strings should be changed. From: -- cgit v1.2.3 From 31f27aa25806670545a7d17f5c6a04d0acd27beb Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 10:35:36 -0400 Subject: Add Active Job info to 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 43b5a0fdaf..f9062920f0 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -340,10 +340,21 @@ Please refer to the [Changelog][active-job] for detailed changes. ### Removals -### Deprecations +* Removed deprecated support to passing the adapter class to `.queue_adapter`. + ([commit](https://github.com/rails/rails/commit/d1fc0a5eb286600abf8505516897b96c2f1ef3f6)) + +* Removed deprecated `#original_exception` in `ActiveJob::DeserializationError`. + ([commit](https://github.com/rails/rails/commit/d861a1fcf8401a173876489d8cee1ede1cecde3b)) ### Notable changes +* Added declarative exception handling via `ActiveJob::Base.retry_on` and `ActiveJob::Base.discard_on`. + ([Pull Request](https://github.com/rails/rails/pull/25991)) + +* Yield the job instance so you have access to things like `job.arguments` on + the custom logic after retries fail. + ([commit](https://github.com/rails/rails/commit/a1e4c197cb12fef66530a2edfaeda75566088d1f)) + Active Support -------------- -- cgit v1.2.3 From 3ec76256e88d36e251c388921d0fd172e86fa297 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 10:39:30 -0400 Subject: Finish Action Mailer section in release notes [ci skip] --- guides/source/5_1_release_notes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index f9062920f0..6c9b519605 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -279,12 +279,12 @@ Action Mailer Please refer to the [Changelog][action-mailer] for detailed changes. -### Removals - -### Deprecations - ### Notable changes +* Exception handling: use `rescue_from` to handle exceptions raised by + mailer actions, by message delivery, and by deferred delivery jobs. + ([commit](https://github.com/rails/rails/commit/e35b98e6f5c54330245645f2ed40d56c74538902)) + * Allowed setting custom content type when attachments are included and body is set inline. ([Pull Request](https://github.com/rails/rails/pull/27227)) -- cgit v1.2.3 From 334d4cd3c75966a44239c7f31507fc1b4ecd1c85 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 10:48:41 -0400 Subject: Finish Action Cable section in release notes [ci skip] --- guides/source/5_1_release_notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 6c9b519605..27a7a748bd 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -252,6 +252,12 @@ Please refer to the [Changelog][action-cable] for detailed changes. with multiple applications. ([Pull Request](https://github.com/rails/rails/pull/27425)) +* Permit same-origin connections by default. + ([commit](https://github.com/rails/rails/commit/dae404473409fcab0e07976aec626df670e52282)) + +* Add `ActiveSupport::Notifications` hook for broadcasing data. + ([Pull Request](https://github.com/rails/rails/pull/24988)) + Action Pack ----------- -- cgit v1.2.3 From 13eb67309ef31f2b61b74639ae8234adee3b9eac Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 10:49:19 -0400 Subject: Remove unused headings [ci skip] --- guides/source/5_1_release_notes.md | 4 ---- 1 file changed, 4 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 27a7a748bd..371ef73c4b 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -241,10 +241,6 @@ Action Cable Please refer to the [Changelog][action-cable] for detailed changes. -### Removals - -### Deprecations - ### Notable changes * Added support for `channel_prefix` to Redis and evented Redis adapters -- cgit v1.2.3 From 87367703b35bddf9b63cc96ced90a75e214e5a77 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 10:57:51 -0400 Subject: Add Active Model info to 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 371ef73c4b..1bfb6491f3 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -331,10 +331,21 @@ Please refer to the [Changelog][active-model] for detailed changes. ### Removals -### Deprecations +* Removed deprecated methods in `ActiveModel::Errors`. + ([commit](https://github.com/rails/rails/commit/9de6457ab0767ebab7f2c8bc583420fda072e2bd)) + +* Removed deprecated `:tokenizer` option in the length validator. + ([commit](https://github.com/rails/rails/commit/6a78e0ecd6122a6b1be9a95e6c4e21e10e429513)) + +* Remove deprecated behavior that halts callbacks when the return value is false. + ([commit](https://github.com/rails/rails/commit/3a25cdca3e0d29ee2040931d0cb6c275d612dffe)) ### Notable changes +* The original string assigned to a model attribute is no longer incorrectly + frozen. + ([Pull Request](https://github.com/rails/rails/pull/28729)) + Active Job ----------- -- cgit v1.2.3 From ee9f97de94fef19550da3006f36e5090d138cdbc Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 11:10:24 -0400 Subject: Add Railties info to 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 1bfb6491f3..be978295e2 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -232,10 +232,46 @@ Please refer to the [Changelog][railties] for detailed changes. ### Removals +* Remove deprecated `config.static_cache_control`. + ([commit](https://github.com/rails/rails/commit/c861decd44198f8d7d774ee6a74194d1ac1a5a13) + +* Remove deprecated `config.serve_static_files`. + ([commit](https://github.com/rails/rails/commit/0129ca2eeb6d5b2ea8c6e6be38eeb770fe45f1fa)) + +* Remove deprecated file `rails/rack/debugger`. + ([commit](https://github.com/rails/rails/commit/7563bf7b46e6f04e160d664e284a33052f9804b8)) + +* Remove deprecated tasks: `rails:update`, `rails:template`, `rails:template:copy`, + `rails:update:configs` and `rails:update:bin`. + ([commit](https://github.com/rails/rails/commit/f7782812f7e727178e4a743aa2874c078b722eef)) + +* Remove deprecated `CONTROLLER` environment variable for `routes` task. + ([commit](https://github.com/rails/rails/commit/f9ed83321ac1d1902578a0aacdfe55d3db754219)) + +* Remove -j (--javascript) option from `rails new` command. + ([Pull Request](https://github.com/rails/rails/pull/28546)) + ### Deprecations ### Notable changes +* The config file `secrets.yml` is now loaded in with all keys as symbols. + ([Pull Request](https://github.com/rails/rails/pull/26929)) + +* Removed jquery-rails from default stack. rails-ujs, which is shipped + with Action View, is included as default UJS adapter. + ([Pull Request](https://github.com/rails/rails/pull/27113)) + +* Add Yarn support in new apps with a yarn binstub and package.json. + ([Pull Request](https://github.com/rails/rails/pull/26836)) + +* Add Webpack support in new apps via the --webpack option, which will delegate + to the rails/webpacker gem. + ([Pull Request](https://github.com/rails/rails/pull/27288)) + +* Add encrypted secrets in `config/secrets.yml.enc`. + ([Pull Request](https://github.com/rails/rails/pull/28038)) + Action Cable ----------- -- cgit v1.2.3 From 3be448a3ba06cedd9edcfc33da92a7f94004efd1 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 11:14:35 -0400 Subject: Add more Railties notable changes [ci skip] --- guides/source/5_1_release_notes.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index be978295e2..cb01c6d6df 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -255,6 +255,10 @@ Please refer to the [Changelog][railties] for detailed changes. ### Notable changes +* Added a shared section to `config/secrets.yml` that will be loaded for all + environments. + ([commit](https://github.com/rails/rails/commit/e530534265d2c32b5c5f772e81cb9002dcf5e9cf)) + * The config file `secrets.yml` is now loaded in with all keys as symbols. ([Pull Request](https://github.com/rails/rails/pull/26929)) @@ -269,6 +273,10 @@ Please refer to the [Changelog][railties] for detailed changes. to the rails/webpacker gem. ([Pull Request](https://github.com/rails/rails/pull/27288)) +* Initialize Git repo when generating new app, if option `--skip-git` is not + provided. + ([Pull Request](https://github.com/rails/rails/pull/27632)) + * Add encrypted secrets in `config/secrets.yml.enc`. ([Pull Request](https://github.com/rails/rails/pull/28038)) -- cgit v1.2.3 From fd7ed5c07db51f5d7053d5c831186ed8c212d831 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 11:15:31 -0400 Subject: Remove unused heading [ci skip] --- guides/source/5_1_release_notes.md | 2 -- 1 file changed, 2 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index cb01c6d6df..ed6802e457 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -251,8 +251,6 @@ Please refer to the [Changelog][railties] for detailed changes. * Remove -j (--javascript) option from `rails new` command. ([Pull Request](https://github.com/rails/rails/pull/28546)) -### Deprecations - ### Notable changes * Added a shared section to `config/secrets.yml` that will be loaded for all -- cgit v1.2.3 From c9d7eeb9dbca7b1cae877d1a02832861dce6691e Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 12:24:05 -0400 Subject: Small grammar fixes [ci skip] --- guides/source/upgrading_ruby_on_rails.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'guides') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 3284a6c77e..ff747a95a0 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -73,21 +73,20 @@ For more information on changes made to Rails 5.1 please see the [release notes] ### Top-level `HashWithIndifferentAccess` is soft-deprecated If your application uses the the top-level `HashWithIndifferentAccess` class, you -should slowly move your code to use the `ActiveSupport::HashWithIndifferentAccess` -one. +should slowly move your code to instead use `ActiveSupport::HashWithIndifferentAccess`. It is only soft-deprecated, which means that your code will not break at the -moment and no deprecation warning will be displayed but this constant will be +moment and no deprecation warning will be displayed, but this constant will be removed in the future. Also, if you have pretty old YAML documents containing dumps of such objects, you may need to load and dump them again to make sure that they reference -the right constant and that loading them won't break in the future. +the right constant, and that loading them won't break in the future. -### `config.secrets` now load with all keys as symbols +### `config.secrets` now loaded with all keys as symbols -If you application stores nested configuration in `secrets.yml` now all keys are being -loaded as symbols so access using strings should be changed. +If your application stores nested configuration in `config/secrets.yml`, all keys +are now loaded as symbols, so access using strings should be changed. From: -- cgit v1.2.3 From 295b2025d8eddbc7fbfbfceac0ea4f90fe34da69 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 12:28:14 -0400 Subject: Use parameters, not params Reads better to use the full word. [ci skip] --- guides/source/5_1_release_notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index ed6802e457..a37e2b01ad 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -101,8 +101,8 @@ Secrets will be decrypted in production, using a key stored either in the [Pull Request](https://github.com/rails/rails/pull/27825) -Allows specifying common params used for all methods in a mailer class -to share instance variables, headers and other common setup. +Allows specifying common parameters used for all methods in a mailer class in +order to share instance variables, headers and other common setup. ``` ruby class InvitationsMailer < ApplicationMailer -- cgit v1.2.3 From 269e11598ce09a61a9ccbb0ec81eed9424610283 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 12:48:07 -0400 Subject: Add Action View info to 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index a37e2b01ad..9a810368b1 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -314,10 +314,33 @@ Please refer to the [Changelog][action-view] for detailed changes. ### Removals +* Removed deprecated `#original_exception` in `ActionView::Template::Error`. + ([commit](https://github.com/rails/rails/commit/b9ba263e5aaa151808df058f5babfed016a1879f)) + +* Remove the option `encode_special_chars` misnomer from `strip_tags`. + ([Pull Request](https://github.com/rails/rails/pull/28061)) + ### Deprecations +* Deprecated Erubis ERB handler in favor of Erubi. + ([Pull Request](https://github.com/rails/rails/pull/27757)) + ### Notable changes +* Raw template handler (the default template handler in Rails 5) now outputs + HTML-safe strings. + ([commit](https://github.com/rails/rails/commit/1de0df86695f8fa2eeae6b8b46f9b53decfa6ec8)) + +* Change `datetime_field` and `datetime_field_tag` to generate `datetime-local` + fields. + ([Pull Request](https://github.com/rails/rails/pull/28061)) + +* New Builder-style syntax for HTML tags (`tag.div`, `tag.br`, etc.) + ([Pull Request](https://github.com/rails/rails/pull/25543)) + +* Add `form_with` to unify `form_tag` and `form_for` usage. + ([Pull Request](https://github.com/rails/rails/pull/26976)) + Action Mailer ------------- -- cgit v1.2.3 From 0dd40fe72cfcf53b475a4084d61e9e931417c29e Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Sun, 23 Apr 2017 13:03:01 -0400 Subject: secrets.yml --> config/secrets.yml [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 9a810368b1..ffa18f1a2b 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -257,7 +257,7 @@ Please refer to the [Changelog][railties] for detailed changes. environments. ([commit](https://github.com/rails/rails/commit/e530534265d2c32b5c5f772e81cb9002dcf5e9cf)) -* The config file `secrets.yml` is now loaded in with all keys as symbols. +* The config file `config/secrets.yml` is now loaded in with all keys as symbols. ([Pull Request](https://github.com/rails/rails/pull/26929)) * Removed jquery-rails from default stack. rails-ujs, which is shipped -- cgit v1.2.3 From 247dace670d3f29a435b43e03a38816371090f6b Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 25 Apr 2017 07:34:39 +0900 Subject: Add `form_with_generates_remote_forms` to configuring guide [ci skip] --- guides/source/configuring.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index ae70b06996..3cfb3e2d6a 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -543,6 +543,8 @@ encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. * `config.action_view.debug_missing_translation` determines whether to wrap the missing translations key in a `` tag or not. This defaults to `true`. +* `config.form_with_generates_remote_forms` determines whether `form_with` generates remote forms or not. This defaults to `true`. + ### Configuring Action Mailer There are a number of settings available on `config.action_mailer`: -- cgit v1.2.3 From 53b43df3a40e77ceb64c1e3ee8e7190e1ac6d70e Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Tue, 25 Apr 2017 07:42:49 +0900 Subject: Unify the name of GitHub [ci skip] --- 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 18331bb73b..f3ae5a5b28 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -182,7 +182,7 @@ of the files and folders that Rails created by default: |test/|Unit tests, fixtures, and other test apparatus. These are covered in [Testing Rails Applications](testing.html).| |tmp/|Temporary files (like cache and pid files).| |vendor/|A place for all third-party code. In a typical Rails application this includes vendored gems.| -|.gitignore|This file tells git which files (or patterns) it should ignore. See [Github - Ignoring files](https://help.github.com/articles/ignoring-files) for more info about ignoring files. +|.gitignore|This file tells git which files (or patterns) it should ignore. See [GitHub - Ignoring files](https://help.github.com/articles/ignoring-files) for more info about ignoring files. Hello, Rails! ------------- -- cgit v1.2.3 From c2e3e0d2096836bfb6072af70bd0914a960a50fe Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 24 Apr 2017 19:06:31 -0400 Subject: Add missing `action_view` section of config flag [ci skip] --- 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 3cfb3e2d6a..bf9456a482 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -543,7 +543,7 @@ encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. * `config.action_view.debug_missing_translation` determines whether to wrap the missing translations key in a `` tag or not. This defaults to `true`. -* `config.form_with_generates_remote_forms` determines whether `form_with` generates remote forms or not. This defaults to `true`. +* `config.action_view.form_with_generates_remote_forms` determines whether `form_with` generates remote forms or not. This defaults to `true`. ### Configuring Action Mailer -- cgit v1.2.3 From deba47799ff905f778e0c98a015789a1327d5087 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Tue, 25 Apr 2017 17:44:54 -0700 Subject: Describe the changes in transactional tests --- guides/source/5_1_release_notes.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index ffa18f1a2b..a0fa1680c4 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -225,6 +225,37 @@ can generate form tags based on URLs, scopes or models. ``` +Incompatibilities +----------------- + +The following changes may require immediate action upon upgrade. + +### Transactional tests with multiple connections + +Transactional tests now wrap all Active Record connections in database +transactions. + +When a test spawns additional threads, and those threads obtain database +connections, those connections are now handled specially: + +The threads will share a single connection, which is inside the managed +transaction. This ensures all threads see the database in the same +state, ignoring the outermost transaction. Previously, such additional +connections were unable to see the fixture rows, for example. + +When a thread enters a nested transaction, it will temporarily obtain +exclusive use of the connection, to maintain isolation. + +If your tests currently rely on obtaining a separate, +outside-of-transaction, connection in a spawned thread, you'll need to +switch to more explicit connection management. + +If your tests spawn threads and those threads interact while also using +explicit database transactions, this change may introduce a deadlock. + +The easy way to opt out of this new behavior is to disable transactional +tests on any test cases it affects. + Railties -------- -- cgit v1.2.3 From b6ac50b3ee2ff51203774cc0c2647a437237f396 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 27 Apr 2017 01:57:03 +0900 Subject: s/broadcasing/broadcasting/ [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index a0fa1680c4..9c1e6e7e46 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -324,7 +324,7 @@ Please refer to the [Changelog][action-cable] for detailed changes. * Permit same-origin connections by default. ([commit](https://github.com/rails/rails/commit/dae404473409fcab0e07976aec626df670e52282)) -* Add `ActiveSupport::Notifications` hook for broadcasing data. +* Add `ActiveSupport::Notifications` hook for broadcasting data. ([Pull Request](https://github.com/rails/rails/pull/24988)) Action Pack -- cgit v1.2.3 From 80c58a8d905485e685ac3855029b6016738a61c5 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 00:04:08 +0200 Subject: Some improvements in the 5.1 release notes [ci skip] --- guides/source/5_1_release_notes.md | 60 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 9c1e6e7e46..503498af11 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -40,7 +40,7 @@ Major Features [Pull Request](https://github.com/rails/rails/pull/26836) -Rails 5.1 will allow managing JavaScript dependencies +Rails 5.1 allows managing JavaScript dependencies from NPM via Yarn. This will make it easy to use libraries like React, VueJS or any other library from NPM world. The Yarn support is integrated with the asset pipeline so that all dependencies will work seamlessly with the @@ -70,14 +70,14 @@ offerings. It is no longer required, as the UJS has been rewritten to use plain, vanilla JavaScript. This code now ships inside of Action View as `rails-ujs`. -You can still use the jQuery version if needed, but it is no longer required by default. +You can still use jQuery if needed, but it is no longer required by default. ### System tests [Pull Request](https://github.com/rails/rails/pull/26703) Rails 5.1 has baked-in support for writing Capybara tests, in the form of -System tests. You need no longer worry about configuring Capybara and +System tests. You no longer need to worry about configuring Capybara and database cleaning strategies for such tests. Rails 5.1 provides a wrapper for running tests in Chrome with additional features such as failure screenshots. @@ -86,7 +86,7 @@ screenshots. [Pull Request](https://github.com/rails/rails/pull/28038) -Rails will now allow management of application secrets in a secure way, +Rails now allows management of application secrets in a secure way, building on top of the [sekrets](https://github.com/ahoward/sekrets) gem. Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will @@ -106,33 +106,24 @@ order to share instance variables, headers and other common setup. ``` ruby class InvitationsMailer < ApplicationMailer - before_action { @inviter, @invitee = params[:inviter], params[:invitee] } before_action { @account = params[:inviter].account } def account_invitation mail subject: "#{@inviter.name} invited you to their Basecamp (#{@account.name})" end - - def project_invitation - @project = params[:project] - @summarizer = ProjectInvitationSummarizer.new(@project.bucket) - - mail subject: "#{@inviter.name.familiar} added you to a project in Basecamp (#{@account.name})" - end end -InvitationsMailer.with(inviter: person_a, invitee: person_b).account_invitation.deliver_later +InvitationsMailer.with(inviter: person_a, invitee: person_b) + .account_invitation.deliver_later ``` ### Direct & resolved routes [Pull Request](https://github.com/rails/rails/pull/23138) -Rails 5.1 has added two new methods, `resolve` and `direct`, to the routing -DSL. - -The `resolve` method allows customizing polymorphic mapping of models. +Rails 5.1 adds two new methods, `resolve` and `direct`, to the routing +DSL. The `resolve` method allows customizing polymorphic mapping of models. ``` ruby resource :basket @@ -181,44 +172,57 @@ Before Rails 5.1, there were two interfaces for handling HTML forms: Rails 5.1 combines both of these interfaces with `form_with`, and can generate form tags based on URLs, scopes or models. -``` erb -# Using just a URL: +Using just a URL: +``` erb <%= form_with url: posts_path do |form| %> <%= form.text_field :title %> <% end %> -# => +<%# Will generate %> +

+``` -# Adding a scope prefixes the input field names: +Adding a scope prefixes the input field names: +``` erb <%= form_with scope: :post, url: posts_path do |form| %> <%= form.text_field :title %> <% end %> -# => + +<%# Will generate %> +
+``` -# Using a model infers both the URL and scope: +Using a model infers both the URL and scope: +``` erb <%= form_with model: Post.new do |form| %> <%= form.text_field :title %> <% end %> -# => + +<%# Will generate %> +
+``` -# An existing model makes an update form and fills out field values: +An existing model makes an update form and fills out field values: +``` erb <%= form_with model: Post.first do |form| %> <%= form.text_field :title %> <% end %> -# => + +<%# Will generate %> +
@@ -264,7 +268,7 @@ Please refer to the [Changelog][railties] for detailed changes. ### Removals * Remove deprecated `config.static_cache_control`. - ([commit](https://github.com/rails/rails/commit/c861decd44198f8d7d774ee6a74194d1ac1a5a13) + ([commit](https://github.com/rails/rails/commit/c861decd44198f8d7d774ee6a74194d1ac1a5a13)) * Remove deprecated `config.serve_static_files`. ([commit](https://github.com/rails/rails/commit/0129ca2eeb6d5b2ea8c6e6be38eeb770fe45f1fa)) @@ -298,7 +302,7 @@ Please refer to the [Changelog][railties] for detailed changes. * Add Yarn support in new apps with a yarn binstub and package.json. ([Pull Request](https://github.com/rails/rails/pull/26836)) -* Add Webpack support in new apps via the --webpack option, which will delegate +* Add Webpack support in new apps via the `--webpack` option, which will delegate to the rails/webpacker gem. ([Pull Request](https://github.com/rails/rails/pull/27288)) -- cgit v1.2.3 From 377a07958904633b882b277ff51ada08e1e4d720 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 00:45:06 +0200 Subject: Add some items to the release notes [ci skip] --- guides/source/5_1_release_notes.md | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 503498af11..a24e8766d3 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -338,10 +338,34 @@ Please refer to the [Changelog][action-pack] for detailed changes. ### Removals +* Removed support to non-keyword arguments in `#process`, `#get`, `#post`, + `#patch`, `#put`, `#delete`, and `#head` for the `ActionDispatch::IntegrationTest` + and `ActionController::TestCase` classes. + ([Commit](https://github.com/rails/rails/commit/98b8309569a326910a723f521911e54994b112fb), + [Commit](https://github.com/rails/rails/commit/de9542acd56f60d281465a59eac11e15ca8b3323)) + +* Removed deprecated `ActionDispatch::Callbacks.to_prepare` and + `ActionDispatch::Callbacks.to_cleanup`. + ([Commit](https://github.com/rails/rails/commit/3f2b7d60a52ffb2ad2d4fcf889c06b631db1946b)) + +* Removed deprecated methods related to controller filters. + ([Commit](https://github.com/rails/rails/commit/d7be30e8babf5e37a891522869e7b0191b79b757)) + ### Deprecations +* Deprecated `config.action_controller.raise_on_unfiltered_parameters`. + It doesn't have any effect in Rails 5.1. + ([Commit](https://github.com/rails/rails/commit/c6640fb62b10db26004a998d2ece98baede509e5)) + ### Notable changes +* Added the `direct` and `resolve` methods to the routing DSL. + ([Pull Request](https://github.com/rails/rails/pull/23138)) + +* Added a new `ActionDispatch::SystemTestCase` class to write system tests in + your applications. + ([Pull Request](https://github.com/rails/rails/pull/26703)) + Action View ------------- @@ -413,6 +437,10 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Notable changes +* Transactional tests now wrap all Active Record connections in database + transactions. + ([Pull Request](https://github.com/rails/rails/pull/28726)) + * Skipped comments in the output of `mysqldump` command by default. ([Pull Request](https://github.com/rails/rails/pull/23301)) @@ -475,10 +503,30 @@ Please refer to the [Changelog][active-support] for detailed changes. ### Removals +* Removed the `ActiveSupport::Concurrency::Latch` class. + ([Commit](https://github.com/rails/rails/commit/0d7bd2031b4054fbdeab0a00dd58b1b08fb7fea6)) + +* Removed `halt_callback_chains_on_return_false`. + ([Commit](https://github.com/rails/rails/commit/4e63ce53fc25c3bc15c5ebf54bab54fa847ee02a)) + +* Removed deprecated behavior that halts callbacks when the return is false. + ([Commit](https://github.com/rails/rails/commit/3a25cdca3e0d29ee2040931d0cb6c275d612dffe)) + ### Deprecations +* The top level `HashWithIndifferentAccess` class has been softly deprecated + in favor of the `ActiveSupport::HashWithIndifferentAccess` one. + ([Pull request](https://github.com/rails/rails/pull/28157)) + ### Notable changes +* Fixed duration parsing and traveling to make it consistent across DST changes. + ([Commit](https://github.com/rails/rails/commit/8931916f4a1c1d8e70c06063ba63928c5c7eab1e), + [Pull Request](https://github.com/rails/rails/pull/26597)) + +* Updated Unicode to version 9.0.0. + ([Pull Request](https://github.com/rails/rails/pull/27822)) + * Added `Module#delegate_missing_to` to delegate method calls not defined for the current object to a proxy object. ([Pull Request](https://github.com/rails/rails/pull/23930)) @@ -487,6 +535,12 @@ Please refer to the [Changelog][active-support] for detailed changes. of the current date & time. ([Pull Request](https://github.com/rails/rails/pull/24930)) +* Introduced the `assert_changes` and `assert_no_changes` method for tests. + ([Pull Request](https://github.com/rails/rails/pull/25393)) + +* The `travel` and `travel_to` methods now raise on nested calls. + ([Pull Request](https://github.com/rails/rails/pull/24890)) + Credits ------- -- cgit v1.2.3 From 5b515518212b67b9a20321f1d5e9e23f73670503 Mon Sep 17 00:00:00 2001 From: claudiob Date: Wed, 26 Apr 2017 16:46:32 -0700 Subject: More release notes for Rails 5.1 [ci skip] @dhh most changes that I mentioned in the talk were already there: https://speakerdeck.com/claudiob/rails-5-dot-1-upcoming-features I just added a few that were missing. --- guides/source/5_1_release_notes.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index a24e8766d3..b81d6011ed 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -313,6 +313,9 @@ Please refer to the [Changelog][railties] for detailed changes. * Add encrypted secrets in `config/secrets.yml.enc`. ([Pull Request](https://github.com/rails/rails/pull/28038)) +* Display railtie class name in `rails initializers`. + ([Pull Request](https://github.com/rails/rails/pull/25257)) + Action Cable ----------- @@ -353,6 +356,9 @@ Please refer to the [Changelog][action-pack] for detailed changes. ### Deprecations +* Deprecated `:controller` and `:action` path parameters. + ([Pull Request](https://github.com/rails/rails/pull/23980)) + * Deprecated `config.action_controller.raise_on_unfiltered_parameters`. It doesn't have any effect in Rails 5.1. ([Commit](https://github.com/rails/rails/commit/c6640fb62b10db26004a998d2ece98baede509e5)) @@ -400,6 +406,9 @@ Please refer to the [Changelog][action-view] for detailed changes. * Add `form_with` to unify `form_tag` and `form_for` usage. ([Pull Request](https://github.com/rails/rails/pull/26976)) +* Add `check_parameters` option to `current_page?`. + ([Pull Request](https://github.com/rails/rails/pull/27549)) + Action Mailer ------------- @@ -437,6 +446,15 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Notable changes +* Change Default Primary Keys to BIGINT. + ([Pull Request](https://github.com/rails/rails/pull/26266)) + +* Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+. + ([Commit](https://github.com/rails/rails/commit/65bf1c60053e727835e06392d27a2fb49665484c)) + +* Added support for limits in batch processing. + ([Commit](https://github.com/rails/rails/commit/451437c6f57e66cc7586ec966e530493927098c7)) + * Transactional tests now wrap all Active Record connections in database transactions. ([Pull Request](https://github.com/rails/rails/pull/28726)) @@ -452,6 +470,9 @@ Please refer to the [Changelog][active-record] for detailed changes. * Pass `"-v ON_ERROR_STOP=1"` flag with `psql` command to not suppress SQL errors. ([Pull Request](https://github.com/rails/rails/pull/24773)) +* Add `ActiveRecord::Base.connection_pool.stat`. + ([Pull Request](https://github.com/rails/rails/pull/26988)) + Active Model ------------ @@ -518,6 +539,9 @@ Please refer to the [Changelog][active-support] for detailed changes. in favor of the `ActiveSupport::HashWithIndifferentAccess` one. ([Pull request](https://github.com/rails/rails/pull/28157)) +* Deprecate passing string to `:if` and `:unless` conditional options on `set_callback` and `skip_callback`. + ([Commit](https://github.com/rails/rails/commit/0952552) + ### Notable changes * Fixed duration parsing and traveling to make it consistent across DST changes. @@ -527,6 +551,9 @@ Please refer to the [Changelog][active-support] for detailed changes. * Updated Unicode to version 9.0.0. ([Pull Request](https://github.com/rails/rails/pull/27822)) +* Add Duration#before and #after as aliases for #ago and #since. + ([Pull Request](https://github.com/rails/rails/pull/27721)) + * Added `Module#delegate_missing_to` to delegate method calls not defined for the current object to a proxy object. ([Pull Request](https://github.com/rails/rails/pull/23930)) @@ -541,6 +568,9 @@ Please refer to the [Changelog][active-support] for detailed changes. * The `travel` and `travel_to` methods now raise on nested calls. ([Pull Request](https://github.com/rails/rails/pull/24890)) +* Update `DateTime#change` to support usec and nsec. + ([Pull Request](https://github.com/rails/rails/pull/28242)) + Credits ------- -- cgit v1.2.3 From f52cdaac6336f99d13622ff9bda556a3124a4121 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 26 Apr 2017 20:14:08 -0400 Subject: Pluralize methods [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index b81d6011ed..0f6167f1ee 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -562,7 +562,7 @@ Please refer to the [Changelog][active-support] for detailed changes. of the current date & time. ([Pull Request](https://github.com/rails/rails/pull/24930)) -* Introduced the `assert_changes` and `assert_no_changes` method for tests. +* Introduced the `assert_changes` and `assert_no_changes` methods for tests. ([Pull Request](https://github.com/rails/rails/pull/25393)) * The `travel` and `travel_to` methods now raise on nested calls. -- cgit v1.2.3 From ef291d997d8751e9289cfc148b24d0b9aea81dc8 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 14:50:27 +0200 Subject: Update the JavaScript guide to use `form_with` `form_with` is the new preferred method to deal with generation of HTML forms and it enables Ajax support by default. [ci skip] --- guides/source/working_with_javascript_in_rails.md | 36 +++++------------------ 1 file changed, 7 insertions(+), 29 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 2a6a87c232..2ef7e8d15d 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -153,14 +153,15 @@ Unless you have disabled the Asset Pipeline, provides the JavaScript half, and the regular Ruby view helpers add appropriate tags to your DOM. -### form_for +### form_with -[`form_for`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for) -is a helper that assists with writing forms. `form_for` takes a `:remote` -option. It works like this: +[`form_with`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with) +is a helper that assists with writing forms. By default, `form_with` considers +that your form will be using Ajax ; you can opt-out by specifying the `:local` +option. ```erb -<%= form_for(@article, remote: true) do |f| %> +<%= form_with(model: @article) do |f| %> ... <% end %> ``` @@ -168,7 +169,7 @@ option. It works like this: This will generate the following HTML: ```html - + ... ``` @@ -191,29 +192,6 @@ $(document).ready -> Obviously, you'll want to be a bit more sophisticated than that, but it's a start. You can see more about the events [in the jquery-ujs wiki](https://github.com/rails/jquery-ujs/wiki/ajax). -### form_tag - -[`form_tag`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag) -is very similar to `form_for`. It has a `:remote` option that you can use like -this: - -```erb -<%= form_tag('/articles', remote: true) do %> - ... -<% end %> -``` - -This will generate the following HTML: - -```html -
- ... -
-``` - -Everything else is the same as `form_for`. See its documentation for full -details. - ### link_to [`link_to`](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) -- cgit v1.2.3 From 6ceb7ce162296c1813e95b6a2a68735519028c90 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 15:11:36 +0200 Subject: Add a section with the different Ajax events [ci skip] --- guides/source/working_with_javascript_in_rails.md | 36 +++++++++++++++++++++++ 1 file changed, 36 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 2ef7e8d15d..45dfeee19e 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -153,6 +153,9 @@ Unless you have disabled the Asset Pipeline, provides the JavaScript half, and the regular Ruby view helpers add appropriate tags to your DOM. +You can read below about the different events that are fired dealing with +remote elements inside your application. + ### form_with [`form_with`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with) @@ -242,6 +245,39 @@ this generates Since it's just a `
`, all of the information on `form_for` also applies. +Dealing with Ajax events +------------------------ + +Here are the different events that are fired when you deal with elements +that have a `data-remote` attribute: + +NOTE: All handlers bound to these events are always passed the event object as the +first argument. The table below describes the extra parameters passed after the +event argument. For exemple, if the extra parameters are listed as `xhr, settings`, +then to access them, you would define your handler with `function(event, xhr, settings)`. + +| Event name | Extra parameters | Fired | +|---------------------|------------------|-------------------------------------------------------------| +| `ajax:before` | | Before the whole ajax business, aborts if stopped. | +| `ajax:beforeSend` | xhr, options | Before the request is sent, aborts if stopped. | +| `ajax:send` | xhr | When the request is sent. | +| `ajax:success` | xhr, status, err | After completion, if the response was a success. | +| `ajax:error` | xhr, status, err | After completion, if the response was an error. | +| `ajax:complete` | xhr, status | After the request has been completed, no matter the outcome.| +| `ajax:aborted:file` | elements | If there are non-blank file inputs, aborts if stopped. | + +### Stoppable events + +If you stop `ajax:before` or `ajax:beforeSend` by returning false from the +handler method, the Ajax request will never take place. The `ajax:before` event +is also useful for manipulating form data before serialization. The +`ajax:beforeSend` event is also useful for adding custom request headers. + +If you stop the `ajax:aborted:file` event, the default behavior of allowing the +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. + Server-Side Concerns -------------------- -- cgit v1.2.3 From 1cbf4b17198ede59f7e188ca79ad1bb8dad7dfe1 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 15:13:24 +0200 Subject: Nest Action View remote helpers one level deeper [ci skip] --- guides/source/working_with_javascript_in_rails.md | 8 +++++--- 1 file changed, 5 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 45dfeee19e..544c04f768 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -141,6 +141,8 @@ follow this pattern. Built-in Helpers ---------------------- +### Remote elements + Rails provides a bunch of view helper methods written in Ruby to assist you in generating HTML. Sometimes, you want to add a little Ajax to those elements, and Rails has got your back in those cases. @@ -156,7 +158,7 @@ tags to your DOM. You can read below about the different events that are fired dealing with remote elements inside your application. -### form_with +#### form_with [`form_with`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with) is a helper that assists with writing forms. By default, `form_with` considers @@ -195,7 +197,7 @@ $(document).ready -> Obviously, you'll want to be a bit more sophisticated than that, but it's a start. You can see more about the events [in the jquery-ujs wiki](https://github.com/rails/jquery-ujs/wiki/ajax). -### link_to +#### link_to [`link_to`](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) is a helper that assists with generating links. It has a `:remote` option you @@ -227,7 +229,7 @@ $ -> alert "The article was deleted." ``` -### button_to +#### button_to [`button_to`](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) is a helper that helps you create buttons. It has a `:remote` option that you can call like this: -- cgit v1.2.3 From 7bf580c89e1aa9342073a7e498d3c993a078b6a2 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Thu, 27 Apr 2017 17:40:15 +0200 Subject: Add documentation of data attributes for UJS [ci skip] --- guides/source/working_with_javascript_in_rails.md | 98 ++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 544c04f768..527b244b0d 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -195,7 +195,7 @@ $(document).ready -> ``` Obviously, you'll want to be a bit more sophisticated than that, but it's a -start. You can see more about the events [in the jquery-ujs wiki](https://github.com/rails/jquery-ujs/wiki/ajax). +start. #### link_to @@ -247,6 +247,102 @@ this generates Since it's just a ``, all of the information on `form_for` also applies. +### Customize remote elements + +It is possible to customize the behavior of elements with a `data-remote` +attribute without writing a line of JavaScript. Your can specify extra `data-` +attributes to accomplish this. + +#### `data-method` + +Activating hyperlinks always results in an HTTP GET request. However, if your +application is [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer), +some links are in fact actions that change data on the server and must be +performed with non-GET requests. This attribute allows marking up such links +with an explicit method such as "post", "put" or "delete". + +The way it works is that, when the link is activated, it constructs a hidden form +in the document with the "action" attribute corresponding to "href" value of the +link and the method corresponding to `data-method` value, and submits that form. + +NOTE: Because submitting forms with HTTP methods other than GET and POST isn't +widely supported across browsers, all other HTTP methods are actually sent over +POST with the intended method indicated in the `_method` parameter. Rails +automatically detects and compensates for this. + +#### `data-url` and `data-params` + +Certain elements of your page aren't actually referring to any URL but you would +like them to trigger Ajax calls. Specifying the `data-url` attribute along with +the `data-remote` one will trigger an Ajax call to the given URL. You can also +specify extra parameters through the `data-params` attribute. + +This can be useful to trigger an action on check-boxes for instance: + +```html + +``` + +#### `data-type` + +It is also possible to defines the Ajax `dataType` explicitly when performing +requests for `data-remote` elements through the `data-type` attribute. + +### Confirmations + +You can ask for an extra confirmation of the user by adding a `data-confirm` +attribute on links and forms. The user will be presented a JavaScript `confirm()` +dialog containing the attribute's text. If the user chooses to cancel, the action +doesn't take place. + +Adding this attribute on links will trigger the dialog on click and adding it +on forms will trigger it on submit. For example: + +```erb +<%= link_to "Dangerous zone", dangerous_zone_path, + data: { confirm: 'Are you sure?'} %> +``` + +This generates: + +```html +Dangerous zone +``` + +The attribute is also allowed on form submit buttons. This allows you to customize +the warning message depending on the button which was activated. In this case, +you should **not** have `data-confirm` on the form itself. + +The default confirmation uses a JavaScript confirm dialog, but you can customize +it by listening to the `confirm` event, that is fired just before the confirmation +window appears to the user. To cancel this default confirmation, make the confirm +handler to return `false`. + +### Automatic disabling + +It is also possible to automatically disable an input while the form is submitting +by using the `data-disable-with` attribute. This is to prevent accidental +double-clicks from the user, which could result in duplicate HTTP requests that +the backend may not detect as such. The value of the attribute is text that will +become the new value of the button in its disabled state. + +This also works for links with `data-method` attribute. + +For example: + +```erb +<%= form_with(model: @article.new) do |f| %> + <%= f.submit data: { "disable-with": "Saving..."} %> +<%= end %> +``` + +This generates a form with: + +```html + +``` + Dealing with Ajax events ------------------------ -- cgit v1.2.3 From 2c691f55adbad7a0600f3dc80c371bbbc3fd6b9d Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Thu, 27 Apr 2017 14:09:56 -0700 Subject: Added some more release notes for Active Record [ci skip] --- guides/source/5_1_release_notes.md | 76 +++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 0f6167f1ee..759a445fd8 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -442,8 +442,73 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Removals +* Removed support for passing arguments and block at the same time to + `ActiveRecord::QueryMethods#select`. + ([Commit](https://github.com/rails/rails/commit/4fc3366d9d99a0eb19e45ad2bf38534efbf8c8ce)) + +* Removed deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and + `activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes. + ([Commit](https://github.com/rails/rails/commit/00e3973a311)) + +* Removed deprecated force reload argument in singular and collection association readers. + ([Commit](https://github.com/rails/rails/commit/09cac8c67af)) + +* Removed deprecated support to passing a column to `#quote`. + ([Commit](https://github.com/rails/rails/commit/e646bad5b7c)) + +* Removed deprecated `name` arguments from `#tables`. + ([Commit](https://github.com/rails/rails/commit/d5be101dd02214468a27b6839ffe338cfe8ef5f3)) + +* Removed deprecated behavior of `#tables` and `#table_exists?` to return tables and views + to return only tables and not views. + ([Commit](https://github.com/rails/rails/commit/5973a984c369a63720c2ac18b71012b8347479a8)) + +* Removed deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize` + and `ActiveRecord::StatementInvalid#original_exception`. + ([Commit](https://github.com/rails/rails/commit/bc6c5df4699d3f6b4a61dd12328f9e0f1bd6cf46)) + +* Removed deprecated support of passing a class as a value in a query. + ([Commit](https://github.com/rails/rails/commit/b4664864c972463c7437ad983832d2582186e886)) + +* Removed deprecated support to query using commas on LIMIT. + ([Commit](https://github.com/rails/rails/commit/fc3e67964753fb5166ccbd2030d7382e1976f393)) + +* Removed deprecated `conditions` parameter from `#destroy_all`. + ([Commit](https://github.com/rails/rails/commit/d31a6d1384cd740c8518d0bf695b550d2a3a4e9b)) + +* Removed deprecated `conditions` parameter from `#delete_all`. + ([Commit](https://github.com/rails/rails/pull/27503/commits/e7381d289e4f8751dcec9553dcb4d32153bd922b)) + +* Removed deprecated method `#load_schema_for` in favor of `#load_schema`. + ([Commit](https://github.com/rails/rails/commit/419e06b56c3b0229f0c72d3e4cdf59d34d8e5545)) + +* Removed deprecated `#raise_in_transactional_callbacks` configuration. + ([Commit](https://github.com/rails/rails/commit/8029f779b8a1dd9848fee0b7967c2e0849bf6e07)) + +* Removed deprecated `#use_transactional_fixtures` configuration. + ([Commit](https://github.com/rails/rails/commit/3955218dc163f61c932ee80af525e7cd440514b3)) + ### Deprecations +* Deprecated `error_on_ignored_order_or_limit` flag in favor of + `error_on_ignored_order`. + ([Commit](https://github.com/rails/rails/commit/451437c6f57e66cc7586ec966e530493927098c7)) + +* Deprecated `sanitize_conditions` in favor of `sanitize_sql`. + ([Pull Request](https://github.com/rails/rails/pull/25999)) + +* Deprecated `supports_migrations?` on connection adapters. + ([Pull Request](https://github.com/rails/rails/pull/28172)) + +* Deprecated `Migrator.schema_migrations_table_name`, use `SchemaMigration.table_name` instead. + ([Pull Request](https://github.com/rails/rails/pull/28351)) + +* Deprecated using `#quoted_id` in quoting and type casting. + ([Pull Request](https://github.com/rails/rails/pull/27962)) + +* Deprecated passing `default` argument to `#index_name_exists?`. + ([Pull Request](https://github.com/rails/rails/pull/26930)) + ### Notable changes * Change Default Primary Keys to BIGINT. @@ -473,6 +538,13 @@ Please refer to the [Changelog][active-record] for detailed changes. * Add `ActiveRecord::Base.connection_pool.stat`. ([Pull Request](https://github.com/rails/rails/pull/26988)) +* Inheriting directly from `ActiveRecord::Migration` raises an error. + Specify the Rails version for which the migration was written for. + ([Commit](https://github.com/rails/rails/commit/249f71a22ab21c03915da5606a063d321f04d4d3)) + +* An error is raised when `through` association has ambiguous reflection name. + ([Commit](https://github.com/rails/rails/commit/0944182ad7ed70d99b078b22426cbf844edd3f61)) + Active Model ------------ @@ -537,9 +609,9 @@ Please refer to the [Changelog][active-support] for detailed changes. * The top level `HashWithIndifferentAccess` class has been softly deprecated in favor of the `ActiveSupport::HashWithIndifferentAccess` one. - ([Pull request](https://github.com/rails/rails/pull/28157)) + ([Pull Request](https://github.com/rails/rails/pull/28157)) -* Deprecate passing string to `:if` and `:unless` conditional options on `set_callback` and `skip_callback`. +* Deprecated passing string to `:if` and `:unless` conditional options on `set_callback` and `skip_callback`. ([Commit](https://github.com/rails/rails/commit/0952552) ### Notable changes -- cgit v1.2.3 From 4c18f050b69c4795097255003fe9bb5a650ba7c9 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Thu, 27 Apr 2017 14:09:56 -0700 Subject: Fix indentation [ci skip] --- guides/source/5_1_release_notes.md | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 759a445fd8..73067d29f2 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -442,30 +442,30 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Removals -* Removed support for passing arguments and block at the same time to - `ActiveRecord::QueryMethods#select`. - ([Commit](https://github.com/rails/rails/commit/4fc3366d9d99a0eb19e45ad2bf38534efbf8c8ce)) +* Removed support for passing arguments and block at the same time to + `ActiveRecord::QueryMethods#select`. + ([Commit](https://github.com/rails/rails/commit/4fc3366d9d99a0eb19e45ad2bf38534efbf8c8ce)) -* Removed deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and +* Removed deprecated `activerecord.errors.messages.restrict_dependent_destroy.one` and `activerecord.errors.messages.restrict_dependent_destroy.many` i18n scopes. - ([Commit](https://github.com/rails/rails/commit/00e3973a311)) + ([Commit](https://github.com/rails/rails/commit/00e3973a311)) -* Removed deprecated force reload argument in singular and collection association readers. - ([Commit](https://github.com/rails/rails/commit/09cac8c67af)) +* Removed deprecated force reload argument in singular and collection association readers. + ([Commit](https://github.com/rails/rails/commit/09cac8c67af)) -* Removed deprecated support to passing a column to `#quote`. - ([Commit](https://github.com/rails/rails/commit/e646bad5b7c)) +* Removed deprecated support to passing a column to `#quote`. + ([Commit](https://github.com/rails/rails/commit/e646bad5b7c)) -* Removed deprecated `name` arguments from `#tables`. - ([Commit](https://github.com/rails/rails/commit/d5be101dd02214468a27b6839ffe338cfe8ef5f3)) +* Removed deprecated `name` arguments from `#tables`. + ([Commit](https://github.com/rails/rails/commit/d5be101dd02214468a27b6839ffe338cfe8ef5f3)) -* Removed deprecated behavior of `#tables` and `#table_exists?` to return tables and views - to return only tables and not views. - ([Commit](https://github.com/rails/rails/commit/5973a984c369a63720c2ac18b71012b8347479a8)) +* Removed deprecated behavior of `#tables` and `#table_exists?` to return tables and views + to return only tables and not views. + ([Commit](https://github.com/rails/rails/commit/5973a984c369a63720c2ac18b71012b8347479a8)) -* Removed deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize` - and `ActiveRecord::StatementInvalid#original_exception`. - ([Commit](https://github.com/rails/rails/commit/bc6c5df4699d3f6b4a61dd12328f9e0f1bd6cf46)) +* Removed deprecated `original_exception` argument in `ActiveRecord::StatementInvalid#initialize` + and `ActiveRecord::StatementInvalid#original_exception`. + ([Commit](https://github.com/rails/rails/commit/bc6c5df4699d3f6b4a61dd12328f9e0f1bd6cf46)) * Removed deprecated support of passing a class as a value in a query. ([Commit](https://github.com/rails/rails/commit/b4664864c972463c7437ad983832d2582186e886)) @@ -490,12 +490,12 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Deprecations -* Deprecated `error_on_ignored_order_or_limit` flag in favor of - `error_on_ignored_order`. - ([Commit](https://github.com/rails/rails/commit/451437c6f57e66cc7586ec966e530493927098c7)) +* Deprecated `error_on_ignored_order_or_limit` flag in favor of + `error_on_ignored_order`. + ([Commit](https://github.com/rails/rails/commit/451437c6f57e66cc7586ec966e530493927098c7)) -* Deprecated `sanitize_conditions` in favor of `sanitize_sql`. - ([Pull Request](https://github.com/rails/rails/pull/25999)) +* Deprecated `sanitize_conditions` in favor of `sanitize_sql`. + ([Pull Request](https://github.com/rails/rails/pull/25999)) * Deprecated `supports_migrations?` on connection adapters. ([Pull Request](https://github.com/rails/rails/pull/28172)) -- cgit v1.2.3 From 1005c42a65e8a9027a6abf6a0ff3d3427283a883 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Thu, 27 Apr 2017 18:22:21 -0400 Subject: Small grammar fixes Will backport to 5-1-stable, since the original PR landed there. [ci skip] --- guides/source/working_with_javascript_in_rails.md | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 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 9af1c5438c..047aeae37d 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -161,9 +161,9 @@ remote elements inside your application. #### form_with [`form_with`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with) -is a helper that assists with writing forms. By default, `form_with` considers -that your form will be using Ajax ; you can opt-out by specifying the `:local` -option. +is a helper that assists with writing forms. By default, `form_with` assumes that +your form will be using Ajax. You can opt out of this behavior by +passing the `:local` option `form_with`. ```erb <%= form_with(model: @article) do |f| %> @@ -257,13 +257,13 @@ attributes to accomplish this. Activating hyperlinks always results in an HTTP GET request. However, if your application is [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer), -some links are in fact actions that change data on the server and must be +some links are in fact actions that change data on the server, and must be performed with non-GET requests. This attribute allows marking up such links with an explicit method such as "post", "put" or "delete". The way it works is that, when the link is activated, it constructs a hidden form in the document with the "action" attribute corresponding to "href" value of the -link and the method corresponding to `data-method` value, and submits that form. +link, and the method corresponding to `data-method` value, and submits that form. NOTE: Because submitting forms with HTTP methods other than GET and POST isn't widely supported across browsers, all other HTTP methods are actually sent over @@ -272,8 +272,8 @@ automatically detects and compensates for this. #### `data-url` and `data-params` -Certain elements of your page aren't actually referring to any URL but you would -like them to trigger Ajax calls. Specifying the `data-url` attribute along with +Certain elements of your page aren't actually referring to any URL, but you may want +them to trigger Ajax calls. Specifying the `data-url` attribute along with the `data-remote` one will trigger an Ajax call to the given URL. You can also specify extra parameters through the `data-params` attribute. @@ -286,8 +286,8 @@ This can be useful to trigger an action on check-boxes for instance: #### `data-type` -It is also possible to defines the Ajax `dataType` explicitly when performing -requests for `data-remote` elements through the `data-type` attribute. +It is also possible to define the Ajax `dataType` explicitly while performing +requests for `data-remote` elements, by way of the `data-type` attribute. ### Confirmations @@ -296,7 +296,7 @@ attribute on links and forms. The user will be presented a JavaScript `confirm() dialog containing the attribute's text. If the user chooses to cancel, the action doesn't take place. -Adding this attribute on links will trigger the dialog on click and adding it +Adding this attribute on links will trigger the dialog on click, and adding it on forms will trigger it on submit. For example: ```erb @@ -315,8 +315,8 @@ the warning message depending on the button which was activated. In this case, you should **not** have `data-confirm` on the form itself. The default confirmation uses a JavaScript confirm dialog, but you can customize -it by listening to the `confirm` event, that is fired just before the confirmation -window appears to the user. To cancel this default confirmation, make the confirm +this by listening to the `confirm` event, which is fired just before the confirmation +window appears to the user. To cancel this default confirmation, have the confirm handler to return `false`. ### Automatic disabling @@ -324,7 +324,7 @@ handler to return `false`. It is also possible to automatically disable an input while the form is submitting by using the `data-disable-with` attribute. This is to prevent accidental double-clicks from the user, which could result in duplicate HTTP requests that -the backend may not detect as such. The value of the attribute is text that will +the backend may not detect as such. The value of the attribute is the text that will become the new value of the button in its disabled state. This also works for links with `data-method` attribute. -- cgit v1.2.3 From 8d79eed3e99aa503dfbd37fe262c047f3daf068d Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Thu, 27 Apr 2017 18:28:01 -0400 Subject: Small grammar fix [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index 73067d29f2..ac26b2994a 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -453,7 +453,7 @@ Please refer to the [Changelog][active-record] for detailed changes. * Removed deprecated force reload argument in singular and collection association readers. ([Commit](https://github.com/rails/rails/commit/09cac8c67af)) -* Removed deprecated support to passing a column to `#quote`. +* Removed deprecated support for passing a column to `#quote`. ([Commit](https://github.com/rails/rails/commit/e646bad5b7c)) * Removed deprecated `name` arguments from `#tables`. -- cgit v1.2.3 From 7902c01d1faa27fb9fa0f03bdfb90725780cf540 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Thu, 27 Apr 2017 21:28:45 -0400 Subject: Small grammar fix [ci skip] --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index ac26b2994a..fc79287d4c 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -341,7 +341,7 @@ Please refer to the [Changelog][action-pack] for detailed changes. ### Removals -* Removed support to non-keyword arguments in `#process`, `#get`, `#post`, +* Removed support for non-keyword arguments in `#process`, `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head` for the `ActionDispatch::IntegrationTest` and `ActionController::TestCase` classes. ([Commit](https://github.com/rails/rails/commit/98b8309569a326910a723f521911e54994b112fb), -- cgit v1.2.3 From a9e5457d8cdd1a67a7c6f34a433a9e18057b4222 Mon Sep 17 00:00:00 2001 From: claudiob Date: Fri, 28 Apr 2017 06:10:58 -0700 Subject: 5.1 Release Notes are complete [ci skip] @prathamesh-sonpatki added the last missing commits in #28911. --- guides/source/documents.yaml | 1 - 1 file changed, 1 deletion(-) (limited to 'guides') diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 5fccdcccec..2afef57fc2 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -197,7 +197,6 @@ name: Ruby on Rails 5.1 Release Notes url: 5_1_release_notes.html description: Release notes for Rails 5.1. - work_in_progress: true - name: Ruby on Rails 5.0 Release Notes url: 5_0_release_notes.html -- cgit v1.2.3 From df6aef2518884f65871f719125a972790518fd17 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 29 Apr 2017 13:33:37 +0900 Subject: Remove entries included in 5.0 [ci skip] * `Permit same-origin connections by default` was backported in db70978, 549d732. * `Deprecated `:controller` and `:action` path parameters` was included in 6520ea5. * `Exception handling: use `rescue_from` was included in 6b54316. --- guides/source/5_1_release_notes.md | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index fc79287d4c..ecdb951870 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -328,9 +328,6 @@ Please refer to the [Changelog][action-cable] for detailed changes. with multiple applications. ([Pull Request](https://github.com/rails/rails/pull/27425)) -* Permit same-origin connections by default. - ([commit](https://github.com/rails/rails/commit/dae404473409fcab0e07976aec626df670e52282)) - * Add `ActiveSupport::Notifications` hook for broadcasting data. ([Pull Request](https://github.com/rails/rails/pull/24988)) @@ -356,9 +353,6 @@ Please refer to the [Changelog][action-pack] for detailed changes. ### Deprecations -* Deprecated `:controller` and `:action` path parameters. - ([Pull Request](https://github.com/rails/rails/pull/23980)) - * Deprecated `config.action_controller.raise_on_unfiltered_parameters`. It doesn't have any effect in Rails 5.1. ([Commit](https://github.com/rails/rails/commit/c6640fb62b10db26004a998d2ece98baede509e5)) @@ -416,10 +410,6 @@ Please refer to the [Changelog][action-mailer] for detailed changes. ### Notable changes -* Exception handling: use `rescue_from` to handle exceptions raised by - mailer actions, by message delivery, and by deferred delivery jobs. - ([commit](https://github.com/rails/rails/commit/e35b98e6f5c54330245645f2ed40d56c74538902)) - * Allowed setting custom content type when attachments are included and body is set inline. ([Pull Request](https://github.com/rails/rails/pull/27227)) -- cgit v1.2.3 From 06dfda12aeb7dd1c530169ab96eef09869a3a425 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 30 Apr 2017 16:33:00 +0900 Subject: Fix note about `secrets.yml` [ci skip] The `secrets` method is in `Application` class, not `Configuration` class. --- guides/source/upgrading_ruby_on_rails.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index ff747a95a0..93864db141 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -83,7 +83,7 @@ Also, if you have pretty old YAML documents containing dumps of such objects, you may need to load and dump them again to make sure that they reference the right constant, and that loading them won't break in the future. -### `config.secrets` now loaded with all keys as symbols +### `application.secrets` now loaded with all keys as symbols If your application stores nested configuration in `config/secrets.yml`, all keys are now loaded as symbols, so access using strings should be changed. @@ -91,13 +91,13 @@ are now loaded as symbols, so access using strings should be changed. From: ```ruby -Rails.appplication.config.secrets[:smtp_settings]["address"] +Rails.application.secrets[:smtp_settings]["address"] ``` To: ```ruby -Rails.application.config.secrets[:smtp_settings][:address] +Rails.application.secrets[:smtp_settings][:address] ``` Upgrading from Rails 4.2 to Rails 5.0 -- cgit v1.2.3 From 99c34f269e902c134b67286c9eb782f28ae292a0 Mon Sep 17 00:00:00 2001 From: Alex Kitchens Date: Mon, 1 May 2017 07:48:11 -0500 Subject: Update the Gem Bug Report Templates to 5.1.0 5.1.0 has been released, and the gem templates can reflect that now. --- guides/bug_report_templates/action_controller_gem.rb | 2 +- guides/bug_report_templates/active_job_gem.rb | 2 +- guides/bug_report_templates/active_record_gem.rb | 2 +- guides/bug_report_templates/active_record_migrations_gem.rb | 2 +- guides/bug_report_templates/generic_gem.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'guides') diff --git a/guides/bug_report_templates/action_controller_gem.rb b/guides/bug_report_templates/action_controller_gem.rb index 46fabca3e8..1d059cc2a5 100644 --- a/guides/bug_report_templates/action_controller_gem.rb +++ b/guides/bug_report_templates/action_controller_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "rails", "5.1.0.rc1" + gem "rails", "5.1.0" end require "rack/test" diff --git a/guides/bug_report_templates/active_job_gem.rb b/guides/bug_report_templates/active_job_gem.rb index 71fe356ea0..252b270a0c 100644 --- a/guides/bug_report_templates/active_job_gem.rb +++ b/guides/bug_report_templates/active_job_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activejob", "5.1.0.rc1" + gem "activejob", "5.1.0" end require "minitest/autorun" diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb index a685c257ea..61d4e8d395 100644 --- a/guides/bug_report_templates/active_record_gem.rb +++ b/guides/bug_report_templates/active_record_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activerecord", "5.1.0.rc1" + gem "activerecord", "5.1.0" gem "sqlite3" end diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index b4e822dfe0..0c398e334a 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activerecord", "5.1.0.rc1" + gem "activerecord", "5.1.0" gem "sqlite3" end diff --git a/guides/bug_report_templates/generic_gem.rb b/guides/bug_report_templates/generic_gem.rb index e1b705bea4..4dcd04ea27 100644 --- a/guides/bug_report_templates/generic_gem.rb +++ b/guides/bug_report_templates/generic_gem.rb @@ -8,7 +8,7 @@ end gemfile(true) do source "https://rubygems.org" # Activate the gem you are reporting the issue against. - gem "activesupport", "5.1.0.rc1" + gem "activesupport", "5.1.0" end require "active_support/core_ext/object/blank" -- cgit v1.2.3 From 19a76b8749d961a13a4c485c110a5a35bd0825db Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 2 May 2017 10:17:08 -0400 Subject: Rails secrets is not built on but inspired by Sekrets Put wording in line with http://weblog.rubyonrails.org/2017/4/27/Rails-5-1-final/ --- guides/source/5_1_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/5_1_release_notes.md b/guides/source/5_1_release_notes.md index ecdb951870..fa92b9e5f8 100644 --- a/guides/source/5_1_release_notes.md +++ b/guides/source/5_1_release_notes.md @@ -87,7 +87,7 @@ screenshots. [Pull Request](https://github.com/rails/rails/pull/28038) Rails now allows management of application secrets in a secure way, -building on top of the [sekrets](https://github.com/ahoward/sekrets) gem. +inspired by the [sekrets](https://github.com/ahoward/sekrets) gem. Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will also generate a master key, which must be stored outside of the repository. The -- cgit v1.2.3 From 66cd83d9b959d4c71d429832896a05078d536cde Mon Sep 17 00:00:00 2001 From: Shia Date: Thu, 4 May 2017 12:47:05 +0900 Subject: Use target language's document.yaml [ci skip] Let me build guide with "ko" language, Before: - It try to use guides/source/documents.yaml After: - It try to use guides/source/ko/documents.yaml --- guides/rails_guides/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb index 6f4b0b492c..2a193ca6b5 100644 --- a/guides/rails_guides/helpers.rb +++ b/guides/rails_guides/helpers.rb @@ -15,7 +15,7 @@ module RailsGuides end def documents_by_section - @documents_by_section ||= YAML.load_file(File.expand_path("../../source/#{@lang ? @lang + '/' : ''}documents.yaml", __FILE__)) + @documents_by_section ||= YAML.load_file(File.expand_path("../../source/#{@language ? @language + '/' : ''}documents.yaml", __FILE__)) end def documents_flat -- cgit v1.2.3 From b201474756a2ee493406ad0cb49f49c6873bdc28 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 7 May 2017 04:08:58 +0900 Subject: Should escape meta characters in regexp --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 7741834153..5224d11f45 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1482,7 +1482,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest assert_equal "You have been invited by me@example.com", invite_email.subject assert_equal 'friend@example.com', invite_email.to[0] - assert_match(/Hi friend@example.com/, invite_email.body.to_s) + assert_match(/Hi friend@example\.com/, invite_email.body.to_s) end end ``` -- cgit v1.2.3 From d25eeb85577fc28b3bb47f8ee2c36195f0fc787c Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 8 May 2017 21:55:38 +0900 Subject: Fix link to `assert_nothing_raised` doc [ci skip] The `assert_nothing_raised` was moved to `ActiveSupport::Testing::Assertions` in 3cece0b6574c496605df055a2ebf77177f5b6e7f. --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 5224d11f45..71fb6fb0e8 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -350,7 +350,7 @@ Rails adds some custom assertions of its own to the `minitest` framework: | --------------------------------------------------------------------------------- | ------- | | [`assert_difference(expressions, difference = 1, message = nil) {...}`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference) | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.| | [`assert_no_difference(expressions, message = nil, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference) | Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.| -| [`assert_nothing_raised { block }`](http://api.rubyonrails.org/classes/ActiveSupport/TestCase.html#method-i-assert_nothing_raised) | Ensures that the given block doesn't raise any exceptions.| +| [`assert_nothing_raised { block }`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_nothing_raised) | Ensures that the given block doesn't raise any exceptions.| | [`assert_recognizes(expected_options, path, extras={}, message=nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes) | Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.| | [`assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_generates) | Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.| | [`assert_response(type, message = nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_response) | Asserts that the response comes with a specific status code. You can specify `:success` to indicate 200-299, `:redirect` to indicate 300-399, `:missing` to indicate 404, or `:error` to match the 500-599 range. You can also pass an explicit status number or its symbolic equivalent. For more information, see [full list of status codes](http://rubydoc.info/github/rack/rack/master/Rack/Utils#HTTP_STATUS_CODES-constant) and how their [mapping](http://rubydoc.info/github/rack/rack/master/Rack/Utils#SYMBOL_TO_STATUS_CODE-constant) works.| -- cgit v1.2.3 From 9b28a2ff4add8b55a6a80f5fe33b7bb7d4280746 Mon Sep 17 00:00:00 2001 From: Steven Chanin Date: Tue, 9 May 2017 09:40:20 -0700 Subject: [ci skip] explain async queue and rake tasks [ci skip] --- guides/source/active_job_basics.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index b58ca61848..ee8e652485 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -310,6 +310,12 @@ UserMailer.welcome(@user).deliver_now UserMailer.welcome(@user).deliver_later ``` +NOTE: Using the asynchronous queue from a rake task (for example, to +send an email using `.deliver_later`) will generally not work because rake will +likely end, causing the in-process thread pool to be deleted, before any/all +of the `.deliver_later` emails are processed. To avoid this problem, use +`.deliver_now` or run a persistent queue in development as well. + Internationalization -------------------- -- cgit v1.2.3 From b9d7bd476893345165e38191612f27ec836c44e7 Mon Sep 17 00:00:00 2001 From: Steven Chanin Date: Tue, 9 May 2017 17:18:16 -0700 Subject: Capitalize Rake --- guides/source/active_job_basics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index ee8e652485..978d1b55a4 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -310,8 +310,8 @@ UserMailer.welcome(@user).deliver_now UserMailer.welcome(@user).deliver_later ``` -NOTE: Using the asynchronous queue from a rake task (for example, to -send an email using `.deliver_later`) will generally not work because rake will +NOTE: Using the asynchronous queue from a Rake task (for example, to +send an email using `.deliver_later`) will generally not work because Rake will likely end, causing the in-process thread pool to be deleted, before any/all of the `.deliver_later` emails are processed. To avoid this problem, use `.deliver_now` or run a persistent queue in development as well. -- cgit v1.2.3 From de499d6775efb433ff6b6ffb3503f67e18b54ee9 Mon Sep 17 00:00:00 2001 From: Steven Chanin Date: Tue, 9 May 2017 17:20:37 -0700 Subject: remove the phrase as well [ci skip] --- guides/source/active_job_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 978d1b55a4..443be77934 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -314,7 +314,7 @@ NOTE: Using the asynchronous queue from a Rake task (for example, to send an email using `.deliver_later`) will generally not work because Rake will likely end, causing the in-process thread pool to be deleted, before any/all of the `.deliver_later` emails are processed. To avoid this problem, use -`.deliver_now` or run a persistent queue in development as well. +`.deliver_now` or run a persistent queue in development. Internationalization -- cgit v1.2.3 From bff2ef921f15b19dac482aa0aec22198afcd3249 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 11 May 2017 13:35:01 +0900 Subject: Fix a typo in guide [ci skip] --- guides/source/working_with_javascript_in_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 047aeae37d..cf08c5dd1d 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -351,7 +351,7 @@ that have a `data-remote` attribute: NOTE: All handlers bound to these events are always passed the event object as the first argument. The table below describes the extra parameters passed after the -event argument. For exemple, if the extra parameters are listed as `xhr, settings`, +event argument. For example, if the extra parameters are listed as `xhr, settings`, then to access them, you would define your handler with `function(event, xhr, settings)`. | Event name | Extra parameters | Fired | -- cgit v1.2.3 From b373d84fb2a3d9756f3e0276e4fb52fd2ae09afa Mon Sep 17 00:00:00 2001 From: Cody Boyko Date: Fri, 12 May 2017 20:13:18 +0000 Subject: [ci skip] Mailer fixtures in Testing guide. Update guide to clarify that mailer fixtures are not created when using the mailer generator. --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 71fb6fb0e8..ced88e888c 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1406,7 +1406,7 @@ In order to test that your mailer is working as expected, you can use unit tests For the purposes of unit testing a mailer, fixtures are used to provide an example of how the output _should_ look. Because these are example emails, and not Active Record data like the other fixtures, they are kept in their own subdirectory apart from the other fixtures. The name of the directory within `test/fixtures` directly corresponds to the name of the mailer. So, for a mailer named `UserMailer`, the fixtures should reside in `test/fixtures/user_mailer` directory. -When you generated your mailer, the generator creates stub fixtures for each of the mailers actions. If you didn't use the generator, you'll have to create those files yourself. +If you generated your mailer, the generator does not create stub fixtures for the mailers actions. You'll have to create those files yourself as described above. #### The Basic Test Case -- cgit v1.2.3 From e37283b52eb537bc0a1735968fbcc19a8cc17769 Mon Sep 17 00:00:00 2001 From: JD Gonzales Date: Fri, 12 May 2017 22:54:11 -0500 Subject: Old expression caught to many chars resulting in 404. Added minor change to resolve --- guides/rails_guides/markdown/renderer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/rails_guides/markdown/renderer.rb b/guides/rails_guides/markdown/renderer.rb index 9d43c10be6..7ac3d417a4 100644 --- a/guides/rails_guides/markdown/renderer.rb +++ b/guides/rails_guides/markdown/renderer.rb @@ -93,7 +93,7 @@ HTML def github_file_url(file_path) tree = version || edge - root = file_path[%r{(.+)/}, 1] + root = file_path[%r{(\w+)/}, 1] path = \ case root when "abstract_controller", "action_controller", "action_dispatch" -- cgit v1.2.3 From c4c48b0d2a3df706b720a1aaf2986b61bdfb2ec2 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Fri, 28 Apr 2017 08:56:43 -0700 Subject: Use a more realistic use-case for system test generator It's more likely you'll generate a test for testing users than a users creates test. This is a better example of a real world test. Additionally the users create view is unlikely to have the text "UserCreates" since that is likely generated as well. This is now an example of visiting the users index. --- guides/source/testing.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index ced88e888c..e528b2e2a2 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -610,9 +610,9 @@ 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. ```bash -$ bin/rails generate system_test users_create +$ bin/rails generate system_test users invoke test_unit - create test/system/users_creates_test.rb + create test/system/users_test.rb ``` Here's what a freshly-generated system test looks like: @@ -620,11 +620,11 @@ Here's what a freshly-generated system test looks like: ```ruby require "application_system_test_case" -class UsersCreatesTest < ApplicationSystemTestCase +class UsersTest < ApplicationSystemTestCase # test "visiting the index" do - # visit users_creates_url + # visit users_url # - # assert_selector "h1", text: "UsersCreate" + # assert_selector "h1", text: "Users" # end end ``` -- cgit v1.2.3 From 46adb59b3474351e95ddc2357e67d169d6ffec51 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Fri, 28 Apr 2017 09:01:12 -0700 Subject: Clarify documentation for system test arguments Previously this implied that system tests provided other non-headless drivers when Selenium is the only driver that uses `:using`, `:screen_size` or `:options` arguments. This change clarifies that Selenium is the only non-headless driver. --- guides/source/testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index e528b2e2a2..c0394f927e 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -658,8 +658,8 @@ 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 for non-headless drivers like Selenium), and `:screen_size` to change -the size of the screen for screenshots. +be used by Selenium), and `:screen_size` to change the size of the screen for +screenshots. ```ruby require "test_helper" -- cgit v1.2.3 From d48008f16438c2c9c9c7295f550568b82b95ef9e Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 14 May 2017 21:25:44 +0200 Subject: explain why guide translations need a fork [ci skip] --- guides/source/contributing_to_ruby_on_rails.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 39f4272b3c..2f2962a3e6 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -141,14 +141,15 @@ NOTE: To help our CI servers you should add [ci skip] to your documentation comm Translating Rails Guides ------------------------ -We are happy to have people volunteer to translate the Rails guides into their own language. -If you want to translate the Rails guides in your own language, follows these steps: +We are happy to have people volunteer to translate the Rails guides. Just follow these steps: -* Fork the project (rails/rails). +* Fork https://github.com/rails/rails. * Add a source folder for your own language, for example: *guides/source/it-IT* for Italian. * Copy the contents of *guides/source* into your own language directory and translate them. * Do NOT translate the HTML files, as they are automatically generated. +Note that translations are not submitted to the Rails repository. As detailed above, your work happens in a fork. This is so because in practice documentation maintenance via patches is only sustainable in English. + To generate the guides in HTML format cd into the *guides* directory then run (eg. for it-IT): ```bash -- cgit v1.2.3 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 062e5f2b068fbce74102d7301b58a3cd7c5da883 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sat, 20 May 2017 04:00:13 -0500 Subject: Add :json type to auto_discovery_link_tag This allows auto_discovery_link_tag to support the JSON Feed standard. See https://jsonfeed.org/version/1 for more information. --- guides/source/action_view_overview.md | 2 +- guides/source/layouts_and_rendering.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index c835adeab6..10412128cc 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -419,7 +419,7 @@ image_tag("rails.png") # => diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index 48bb3147f3..caa3d21d23 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -768,7 +768,7 @@ WARNING: The asset tag helpers do _not_ verify the existence of the assets at th #### Linking to Feeds with the `auto_discovery_link_tag` -The `auto_discovery_link_tag` helper builds HTML that most browsers and feed readers can use to detect the presence of RSS or Atom feeds. It takes the type of the link (`:rss` or `:atom`), a hash of options that are passed through to url_for, and a hash of options for the tag: +The `auto_discovery_link_tag` helper builds HTML that most browsers and feed readers can use to detect the presence of RSS, Atom, or JSON feeds. It takes the type of the link (`:rss`, `:atom`, or `:json`), a hash of options that are passed through to url_for, and a hash of options for the tag: ```erb <%= auto_discovery_link_tag(:rss, {action: "feed"}, -- cgit v1.2.3 From 99209b4ec06b2f87b28de5bd7d02b6ed815994e6 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sat, 20 May 2017 09:30:51 -0500 Subject: Update 'Rails on Rack' guide [ci skip] * Adjust middlewares list to match current defaults * application.routes runs on application object, not Rails * Add explanation of Sprockets::Rails::QuietAssets --- guides/source/rails_on_rack.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'guides') diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index f25b185fb5..cef8450ee4 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -110,11 +110,12 @@ use ActiveSupport::Cache::Strategy::LocalCache::Middleware use Rack::Runtime use Rack::MethodOverride use ActionDispatch::RequestId +use ActionDispatch::RemoteIp +use Sprockets::Rails::QuietAssets use Rails::Rack::Logger use ActionDispatch::ShowExceptions use WebConsole::Middleware use ActionDispatch::DebugExceptions -use ActionDispatch::RemoteIp use ActionDispatch::Reloader use ActionDispatch::Callbacks use ActiveRecord::Migration::CheckPending @@ -124,7 +125,7 @@ use ActionDispatch::Flash use Rack::Head use Rack::ConditionalGet use Rack::ETag -run Rails.application.routes +run MyApp.application.routes ``` The default middlewares shown here (and some others) are each summarized in the [Internal Middlewares](#internal-middleware-stack) section, below. @@ -238,6 +239,14 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol * Makes a unique `X-Request-Id` header available to the response and enables the `ActionDispatch::Request#request_id` method. +**`ActionDispatch::RemoteIp`** + +* Checks for IP spoofing attacks. + +**`Sprockets::Rails::QuietAssets`** + +* Suppresses logger output for asset requests. + **`Rails::Rack::Logger`** * Notifies the logs that the request has began. After request is complete, flushes all the logs. @@ -250,10 +259,6 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol * Responsible for logging exceptions and showing a debugging page in case the request is local. -**`ActionDispatch::RemoteIp`** - -* Checks for IP spoofing attacks. - **`ActionDispatch::Reloader`** * Provides prepare and cleanup callbacks, intended to assist with code reloading during development. -- cgit v1.2.3 From 3508909dc8afb76d3781a7282a1cbc4bb5b07a93 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Sun, 21 May 2017 02:29:09 -0700 Subject: Fix typo in guides --- guides/source/working_with_javascript_in_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index cf08c5dd1d..290f2a509b 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -250,7 +250,7 @@ Since it's just a ``, all of the information on `form_with` also applies. ### Customize remote elements It is possible to customize the behavior of elements with a `data-remote` -attribute without writing a line of JavaScript. Your can specify extra `data-` +attribute without writing a line of JavaScript. You can specify extra `data-` attributes to accomplish this. #### `data-method` -- cgit v1.2.3 From d23fb68e3d4b8cc81e877266aefce95dac562699 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 21 May 2017 08:56:24 -0500 Subject: Fix broken external link in security guide. --- 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 c305350243..1fcb2fc91f 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -796,7 +796,7 @@ In December 2006, 34,000 actual user names and passwords were stolen in a [MySpa INFO: _CSS Injection is actually JavaScript injection, because some browsers (IE, some versions of Safari and others) allow JavaScript in CSS. Think twice about allowing custom CSS in your web application._ -CSS Injection is explained best by the well-known [MySpace Samy worm](http://namb.la/popular/tech.html). This worm automatically sent a friend request to Samy (the attacker) simply by visiting his profile. Within several hours he had over 1 million friend requests, which created so much traffic that MySpace went offline. The following is a technical explanation of that worm. +CSS Injection is explained best by the well-known [MySpace Samy worm](https://samy.pl/popular/tech.html). This worm automatically sent a friend request to Samy (the attacker) simply by visiting his profile. Within several hours he had over 1 million friend requests, which created so much traffic that MySpace went offline. The following is a technical explanation of that worm. MySpace blocked many tags, but allowed CSS. So the worm's author put JavaScript into CSS like this: -- cgit v1.2.3 From ea37cb4cb456d2d2feb5b582f0efd53b80e8e5cd Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 21 May 2017 09:19:05 -0500 Subject: Update Rails API Application guide to match current code [ci skip] * Adjust list of middlewares loaded by default * Add routing middleware to list to match the list in the Rack guide * Adjust list of Controller modules loaded by default Plus fix one singular/plural mistake --- guides/source/api_app.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'guides') diff --git a/guides/source/api_app.md b/guides/source/api_app.md index f373d313cc..64200ec242 100644 --- a/guides/source/api_app.md +++ b/guides/source/api_app.md @@ -206,16 +206,17 @@ An API application comes with the following middleware by default: - `ActiveSupport::Cache::Strategy::LocalCache::Middleware` - `Rack::Runtime` - `ActionDispatch::RequestId` +- `ActionDispatch::RemoteIp` - `Rails::Rack::Logger` - `ActionDispatch::ShowExceptions` - `ActionDispatch::DebugExceptions` -- `ActionDispatch::RemoteIp` - `ActionDispatch::Reloader` - `ActionDispatch::Callbacks` - `ActiveRecord::Migration::CheckPending` - `Rack::Head` - `Rack::ConditionalGet` - `Rack::ETag` +- `MyApi::Application::Routes` See the [internal middleware](rails_on_rack.html#internal-middleware-stack) section of the Rack guide for further information on them. @@ -360,7 +361,7 @@ middleware set, you can remove it with: config.middleware.delete ::Rack::Sendfile ``` -Keep in mind that removing these middleware will remove support for certain +Keep in mind that removing these middlewares will remove support for certain features in Action Controller. Choosing Controller Modules @@ -385,8 +386,9 @@ controller modules by default: hooks defined by Action Controller (see [the instrumentation guide](active_support_instrumentation.html#action-controller) for more information regarding this). -- `ActionController::ParamsWrapper`: Wraps the parameters hash into a nested hash, +- `ActionController::ParamsWrapper`: Wraps the parameters hash into a nested hash, so that you don't have to specify root elements sending POST requests for instance. +- `ActionController::Head`: Support for returning a response with no content, only headers Other plugins may add additional modules. You can get a list of all modules included into `ActionController::API` in the rails console: @@ -394,12 +396,12 @@ included into `ActionController::API` in the rails console: ```bash $ bin/rails c >> ActionController::API.ancestors - ActionController::Metal.ancestors -=> [ActionController::API, - ActiveRecord::Railties::ControllerRuntime, - ActionDispatch::Routing::RouteSet::MountedHelpers, - ActionController::ParamsWrapper, - ... , - AbstractController::Rendering, +=> [ActionController::API, + ActiveRecord::Railties::ControllerRuntime, + ActionDispatch::Routing::RouteSet::MountedHelpers, + ActionController::ParamsWrapper, + ... , + AbstractController::Rendering, ActionView::ViewPaths] ``` -- cgit v1.2.3 From 1a5d93999fe83e45ee98e0e28c77f37b13af669b Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 21 May 2017 10:00:20 -0500 Subject: Remove obsolete Guides source files [ci skip] * Nested Model Forms guide is out of date, not linked from index, and material is covered in the Form Helpers guide. * Profiling guide was committed as an outline years ago and never actually written. --- guides/source/nested_model_forms.md | 230 ------------------------------------ guides/source/profiling.md | 16 --- 2 files changed, 246 deletions(-) delete mode 100644 guides/source/nested_model_forms.md delete mode 100644 guides/source/profiling.md (limited to 'guides') diff --git a/guides/source/nested_model_forms.md b/guides/source/nested_model_forms.md deleted file mode 100644 index 71efa4b0d0..0000000000 --- a/guides/source/nested_model_forms.md +++ /dev/null @@ -1,230 +0,0 @@ -**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** - -Rails Nested Model Forms -======================== - -Creating a form for a model _and_ its associations can become quite tedious. Therefore Rails provides helpers to assist in dealing with the complexities of generating these forms _and_ the required CRUD operations to create, update, and destroy associations. - -After reading this guide, you will know: - -* do stuff. - --------------------------------------------------------------------------------- - -NOTE: This guide assumes the user knows how to use the [Rails form helpers](form_helpers.html) in general. Also, it's **not** an API reference. For a complete reference please visit [the Rails API documentation](http://api.rubyonrails.org/). - - -Model setup ------------ - -To be able to use the nested model functionality in your forms, the model will need to support some basic operations. - -First of all, it needs to define a writer method for the attribute that corresponds to the association you are building a nested model form for. The `fields_for` form helper will look for this method to decide whether or not a nested model form should be built. - -If the associated object is an array, a form builder will be yielded for each object, else only a single form builder will be yielded. - -Consider a Person model with an associated Address. When asked to yield a nested FormBuilder for the `:address` attribute, the `fields_for` form helper will look for a method on the Person instance named `address_attributes=`. - -### ActiveRecord::Base model - -For an ActiveRecord::Base model and association this writer method is commonly defined with the `accepts_nested_attributes_for` class method: - -#### has_one - -```ruby -class Person < ApplicationRecord - has_one :address - accepts_nested_attributes_for :address -end -``` - -#### belongs_to - -```ruby -class Person < ApplicationRecord - belongs_to :firm - accepts_nested_attributes_for :firm -end -``` - -#### has_many / has_and_belongs_to_many - -```ruby -class Person < ApplicationRecord - has_many :projects - accepts_nested_attributes_for :projects -end -``` - -NOTE: For greater detail on associations see [Active Record Associations](association_basics.html). -For a complete reference on associations please visit the API documentation for [ActiveRecord::Associations::ClassMethods](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html). - -### Custom model - -As you might have inflected from this explanation, you _don't_ necessarily need an ActiveRecord::Base model to use this functionality. The following examples are sufficient to enable the nested model form behavior: - -#### Single associated object - -```ruby -class Person - def address - Address.new - end - - def address_attributes=(attributes) - # ... - end -end -``` - -#### Association collection - -```ruby -class Person - def projects - [Project.new, Project.new] - end - - def projects_attributes=(attributes) - # ... - end -end -``` - -NOTE: See (TODO) in the advanced section for more information on how to deal with the CRUD operations in your custom model. - -Views ------ - -### Controller code - -A nested model form will _only_ be built if the associated object(s) exist. This means that for a new model instance you would probably want to build the associated object(s) first. - -Consider the following typical RESTful controller which will prepare a new Person instance and its `address` and `projects` associations before rendering the `new` template: - -```ruby -class PeopleController < ApplicationController - def new - @person = Person.new - @person.build_address - 2.times { @person.projects.build } - end - - def create - @person = Person.new(params[:person]) - if @person.save - # ... - end - end -end -``` - -NOTE: Obviously the instantiation of the associated object(s) can become tedious and not DRY, so you might want to move that into the model itself. ActiveRecord::Base provides an `after_initialize` callback which is a good way to refactor this. - -### Form code - -Now that you have a model instance, with the appropriate methods and associated object(s), you can start building the nested model form. - -#### Standard form - -Start out with a regular RESTful form: - -```erb -<%= form_for @person do |f| %> - <%= f.text_field :name %> -<% end %> -``` - -This will generate the following html: - -```html - - - -``` - -#### Nested form for a single associated object - -Now add a nested form for the `address` association: - -```erb -<%= form_for @person do |f| %> - <%= f.text_field :name %> - - <%= f.fields_for :address do |af| %> - <%= af.text_field :street %> - <% end %> -<% end %> -``` - -This generates: - -```html -
- - - -
-``` - -Notice that `fields_for` recognized the `address` as an association for which a nested model form should be built by the way it has namespaced the `name` attribute. - -When this form is posted the Rails parameter parser will construct a hash like the following: - -```ruby -{ - "person" => { - "name" => "Eloy Duran", - "address_attributes" => { - "street" => "Nieuwe Prinsengracht" - } - } -} -``` - -That's it. The controller will simply pass this hash on to the model from the `create` action. The model will then handle building the `address` association for you and automatically save it when the parent (`person`) is saved. - -#### Nested form for a collection of associated objects - -The form code for an association collection is pretty similar to that of a single associated object: - -```erb -<%= form_for @person do |f| %> - <%= f.text_field :name %> - - <%= f.fields_for :projects do |pf| %> - <%= pf.text_field :name %> - <% end %> -<% end %> -``` - -Which generates: - -```html -
- - - - -
-``` - -As you can see it has generated 2 `project name` inputs, one for each new `project` that was built in the controller's `new` action. Only this time the `name` attribute of the input contains a digit as an extra namespace. This will be parsed by the Rails parameter parser as: - -```ruby -{ - "person" => { - "name" => "Eloy Duran", - "projects_attributes" => { - "0" => { "name" => "Project 1" }, - "1" => { "name" => "Project 2" } - } - } -} -``` - -You can basically see the `projects_attributes` hash as an array of attribute hashes, one for each model instance. - -NOTE: The reason that `fields_for` constructed a hash instead of an array is that it won't work for any form nested deeper than one level deep. - -TIP: You _can_ however pass an array to the writer method generated by `accepts_nested_attributes_for` if you're using plain Ruby or some other API access. See (TODO) for more info and example. diff --git a/guides/source/profiling.md b/guides/source/profiling.md deleted file mode 100644 index ce093f78ba..0000000000 --- a/guides/source/profiling.md +++ /dev/null @@ -1,16 +0,0 @@ -*DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** - -A Guide to Profiling Rails Applications -======================================= - -This guide covers built-in mechanisms in Rails for profiling your application. - -After reading this guide, you will know: - -* Rails profiling terminology. -* How to write benchmark tests for your application. -* Other benchmarking approaches and plugins. - --------------------------------------------------------------------------------- - - -- cgit v1.2.3 From 4f3955657736796664aa8d6f6d149ef9b213b058 Mon Sep 17 00:00:00 2001 From: dixpac Date: Sat, 13 May 2017 13:56:37 +0200 Subject: Improving docs for callbacks execution order [ci skip] When define callbacks latest definition on the same callback/method overwrites previous ones. --- guides/source/action_controller_overview.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 5d987264f5..22537f960c 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -715,6 +715,9 @@ end Now, the `LoginsController`'s `new` and `create` actions will work as before without requiring the user to be logged in. The `:only` option is used to skip this filter only for these actions, and there is also an `:except` option which works the other way. These options can be used when adding filters too, so you can add a filter which only runs for selected actions in the first place. +NOTE: Calling the same filter multiple times with different options will not work, +since the last filter definition will overwrite the previous ones. + ### After Filters and Around Filters In addition to "before" filters, you can also run filters after an action has been executed, or both before and after. -- cgit v1.2.3 From 65cc7b228d97b717d7d143148c21eaed1a7dafdd Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 21 May 2017 13:06:33 -0500 Subject: Simplify handling of prerequisites in Getting Started guide [ci skip] Telling people about prerequisites, and then telling them a page later how to check and install those prerequisites, is confusing. This commit removes the list and just handles the software installation in one place. Fixes #28565 --- guides/source/getting_started.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'guides') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index f3ae5a5b28..5553f08456 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -20,16 +20,7 @@ Guide Assumptions This guide is designed for beginners who want to get started with a Rails application from scratch. It does not assume that you have any prior experience -with Rails. However, to get the most out of it, you need to have some -prerequisites installed: - -* The [Ruby](https://www.ruby-lang.org/en/downloads) language version 2.2.2 or newer. -* Right version of [Development Kit](http://rubyinstaller.org/downloads/), if you - are using Windows. -* The [RubyGems](https://rubygems.org) packaging system, which is installed with - Ruby by default. To learn more about RubyGems, please read the - [RubyGems Guides](http://guides.rubygems.org). -* A working installation of the [SQLite3 Database](https://www.sqlite.org). +with Rails. Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, you will find a very steep learning @@ -86,6 +77,9 @@ your prompt will look something like `c:\source_code>` ### Installing Rails +Before you install Rails, you should check to make sure that your system has the +proper prerequisites installed. These include Ruby and SQLite3. + Open up a command line prompt. On macOS open Terminal.app, on Windows choose "Run" from your Start menu and type 'cmd.exe'. Any commands prefaced with a dollar sign `$` should be run in the command line. Verify that you have a @@ -96,12 +90,19 @@ $ ruby -v ruby 2.3.1p112 ``` +Rails requires Ruby version 2.2.2 or later. If the version number returned is +less than that number, you'll need to install a fresh copy of Ruby. + TIP: A number of tools exist to help you quickly install Ruby and Ruby on Rails on your system. Windows users can use [Rails Installer](http://railsinstaller.org), while macOS users can use [Tokaido](https://github.com/tokaido/tokaidoapp). For more installation methods for most Operating Systems take a look at [ruby-lang.org](https://www.ruby-lang.org/en/documentation/installation/). +If you are working on Windows, you should also install the +[Ruby Installer Development Kit](http://rubyinstaller.org/downloads/). + +You will also need an installation of the SQLite3 database. Many popular UNIX-like OSes ship with an acceptable version of SQLite3. On Windows, if you installed Rails through Rails Installer, you already have SQLite installed. Others can find installation instructions @@ -127,7 +128,7 @@ run the following: $ rails --version ``` -If it says something like "Rails 5.1.0", you are ready to continue. +If it says something like "Rails 5.1.1", you are ready to continue. ### Creating the Blog Application @@ -1195,7 +1196,7 @@ it look as follows: This time we point the form to the `update` action, which is not defined yet but will be very soon. -Passing the article object to the method, will automagically create url for submitting the edited article form. +Passing the article object to the method, will automagically create url for submitting the edited article form. This option tells Rails that we want this form to be submitted via the `PATCH` HTTP method which is the HTTP method you're expected to use to **update** resources according to the REST protocol. -- cgit v1.2.3 From d414881a342d849d65810a037c0b1baff8538e41 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 22 May 2017 08:44:42 +0900 Subject: We always + 1 to __LINE__ when class_evaling with << [ci skip] --- guides/source/api_documentation_guidelines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/api_documentation_guidelines.md b/guides/source/api_documentation_guidelines.md index 3c61754982..c3c7367304 100644 --- a/guides/source/api_documentation_guidelines.md +++ b/guides/source/api_documentation_guidelines.md @@ -281,7 +281,7 @@ Methods created with `(module|class)_eval(STRING)` have a comment by their side ```ruby for severity in Severity.constants - class_eval <<-EOT, __FILE__, __LINE__ + class_eval <<-EOT, __FILE__, __LINE__ + 1 def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block) add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block) end # end -- cgit v1.2.3 From 5a3ba63d9abad86b7f6dd36a92cfaf722e52760b Mon Sep 17 00:00:00 2001 From: Michael Coyne Date: Thu, 23 Feb 2017 13:54:17 -0500 Subject: AEAD encrypted cookies and sessions This commit changes encrypted cookies from AES in CBC HMAC mode to Authenticated Encryption using AES-GCM. It also provides a cookie jar to transparently upgrade encrypted cookies to this new scheme. Some other notable changes include: - There is a new application configuration value: +use_authenticated_cookie_encryption+. When enabled, AEAD encrypted cookies will be used. - +cookies.signed+ does not raise a +TypeError+ now if the name of an encrypted cookie is used. Encrypted cookies using the same key as signed cookies would be verified and serialization would then fail due the message still be encrypted. --- guides/source/configuring.md | 8 ++++++-- guides/source/security.md | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index bf9456a482..6a7eaf00e1 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -456,10 +456,14 @@ to `'http authentication'`. Defaults to `'signed cookie'`. * `config.action_dispatch.encrypted_cookie_salt` sets the encrypted cookies salt -value. Defaults to `'encrypted cookie'`. + value. Defaults to `'encrypted cookie'`. * `config.action_dispatch.encrypted_signed_cookie_salt` sets the signed -encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. + encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. + +* `config.action_dispatch.authenticated_encrypted_cookie_salt` sets the + authenticated encrypted cookie salt. Defaults to `'authenticated encrypted + cookie'`. * `config.action_dispatch.perform_deep_munge` configures whether `deep_munge` method should be performed on the parameters. See [Security Guide](security.html#unsafe-query-generation) diff --git a/guides/source/security.md b/guides/source/security.md index c305350243..61b0c5e368 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -95,16 +95,23 @@ Rails 2 introduced a new default session storage, CookieStore. CookieStore saves * The client can see everything you store in a session, because it is stored in clear-text (actually Base64-encoded, so not encrypted). So, of course, _you don't want to store any secrets here_. To prevent session hash tampering, a digest is calculated from the session with a server-side secret (`secrets.secret_token`) and inserted into the end of the cookie. -However, since Rails 4, the default store is EncryptedCookieStore. With -EncryptedCookieStore the session is encrypted before being stored in a cookie. -This prevents the user from accessing and tampering the content of the cookie. -Thus the session becomes a more secure place to store data. The encryption is -done using a server-side secret key `secrets.secret_key_base` stored in -`config/secrets.yml`. +In Rails 4, encrypted cookies through AES in CBC mode with HMAC using SHA1 for +verification was introduced. This prevents the user from accessing and tampering +the content of the cookie. Thus the session becomes a more secure place to store +data. The encryption is performed using a server-side `secrets.secret_key_base`. +Two salts are used when deriving keys for encryption and verification. These +salts are set via the `config.action_dispatch.encrypted_cookie_salt` and +`config.action_dispatch.encrypted_signed_cookie_salt` configuration values. -That means the security of this storage depends on this secret (and on the digest algorithm, which defaults to SHA1, for compatibility). So _don't use a trivial secret, i.e. a word from a dictionary, or one which is shorter than 30 characters, use `rails secret` instead_. +Rails 5.2 uses AES-GCM for the encryption which couples authentication +and encryption in one faster step and produces shorter ciphertexts. -`secrets.secret_key_base` is used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. Applications get `secrets.secret_key_base` initialized to a random key present in `config/secrets.yml`, e.g.: +Encrypted cookies are automatically upgraded if the +`config.action_dispatch.use_authenticated_cookie_encryption` is enabled. + +_Do not use a trivial secret, i.e. a word from a dictionary, or one which is shorter than 30 characters! Instead use `rails secret` to generate secret keys!_ + +Applications get `secrets.secret_key_base` initialized to a random key present in `config/secrets.yml`, e.g.: development: secret_key_base: a75d... -- cgit v1.2.3 From 40bdbce191ad90dfea43dad51fac5c4726b89392 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Mon, 15 May 2017 14:17:28 +0000 Subject: Define path with __dir__ ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f --- guides/bug_report_templates/action_controller_gem.rb | 2 +- guides/bug_report_templates/action_controller_master.rb | 2 +- guides/rails_guides/helpers.rb | 2 +- guides/source/generators.md | 4 ++-- guides/source/rails_application_templates.md | 2 +- guides/source/security.md | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'guides') diff --git a/guides/bug_report_templates/action_controller_gem.rb b/guides/bug_report_templates/action_controller_gem.rb index 1d059cc2a5..8b7aa893fd 100644 --- a/guides/bug_report_templates/action_controller_gem.rb +++ b/guides/bug_report_templates/action_controller_gem.rb @@ -15,7 +15,7 @@ require "rack/test" require "action_controller/railtie" class TestApp < Rails::Application - config.root = File.dirname(__FILE__) + config.root = __dir__ config.session_store :cookie_store, key: "cookie_store_key" secrets.secret_token = "secret_token" secrets.secret_key_base = "secret_key_base" diff --git a/guides/bug_report_templates/action_controller_master.rb b/guides/bug_report_templates/action_controller_master.rb index 7644f6fe4a..3dd66c95ec 100644 --- a/guides/bug_report_templates/action_controller_master.rb +++ b/guides/bug_report_templates/action_controller_master.rb @@ -14,7 +14,7 @@ end require "action_controller/railtie" class TestApp < Rails::Application - config.root = File.dirname(__FILE__) + config.root = __dir__ secrets.secret_token = "secret_token" secrets.secret_key_base = "secret_key_base" diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb index 2a193ca6b5..520aa7f7cc 100644 --- a/guides/rails_guides/helpers.rb +++ b/guides/rails_guides/helpers.rb @@ -15,7 +15,7 @@ module RailsGuides end def documents_by_section - @documents_by_section ||= YAML.load_file(File.expand_path("../../source/#{@language ? @language + '/' : ''}documents.yaml", __FILE__)) + @documents_by_section ||= YAML.load_file(File.expand_path("../source/#{@language ? @language + '/' : ''}documents.yaml", __dir__)) end def documents_flat diff --git a/guides/source/generators.md b/guides/source/generators.md index a554e08204..d4ed2355d4 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -96,7 +96,7 @@ This is the generator just created: ```ruby class InitializerGenerator < Rails::Generators::NamedBase - source_root File.expand_path("../templates", __FILE__) + source_root File.expand_path("templates", __dir__) end ``` @@ -122,7 +122,7 @@ And now let's change the generator to copy this template when invoked: ```ruby class InitializerGenerator < Rails::Generators::NamedBase - source_root File.expand_path("../templates", __FILE__) + source_root File.expand_path("templates", __dir__) def copy_initializer_file copy_file "initializer.rb", "config/initializers/#{file_name}.rb" diff --git a/guides/source/rails_application_templates.md b/guides/source/rails_application_templates.md index 3e99ee7021..e087834a2f 100644 --- a/guides/source/rails_application_templates.md +++ b/guides/source/rails_application_templates.md @@ -277,6 +277,6 @@ relative paths to your template's location. ```ruby def source_paths - [File.expand_path(File.dirname(__FILE__))] + [__dir__] end ``` diff --git a/guides/source/security.md b/guides/source/security.md index 1fcb2fc91f..75522834df 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -356,7 +356,7 @@ send_file('/var/www/uploads/' + params[:filename]) Simply pass a file name like "../../../etc/passwd" to download the server's login information. A simple solution against this, is to _check that the requested file is in the expected directory_: ```ruby -basename = File.expand_path(File.join(File.dirname(__FILE__), '../../files')) +basename = File.expand_path('../../files', __dir__) filename = File.expand_path(File.join(basename, @file.public_filename)) raise if basename != File.expand_path(File.join(File.dirname(filename), '../../../')) -- cgit v1.2.3 From d225f0b94c9d89e8837ee8e98ee3a7837877631b Mon Sep 17 00:00:00 2001 From: willnet Date: Wed, 24 May 2017 13:04:03 +0900 Subject: [ci skip]fix wrong method name in docs --- guides/source/association_basics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 5794bfa666..d8e85497fa 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -599,7 +599,7 @@ class CreateBooks < ActiveRecord::Migration[5.0] t.string :book_number t.integer :author_id end - + add_index :books, :author_id add_foreign_key :books, :authors end @@ -1417,7 +1417,7 @@ If either of these saves fails due to validation errors, then the assignment sta If the parent object (the one declaring the `has_one` association) is unsaved (that is, `new_record?` returns `true`) then the child objects are not saved. They will automatically when the parent object is saved. -If you want to assign an object to a `has_one` association without saving the object, use the `association.build` method. +If you want to assign an object to a `has_one` association without saving the object, use the `build_association` method. ### `has_many` Association Reference -- cgit v1.2.3 From d0854d397ac72e50420e7c86a29db84cc5de4eac Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Wed, 24 May 2017 11:38:57 -0500 Subject: Update information on using Gmail when 2FA is in use [ci skip] --- guides/source/action_mailer_basics.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index 65146ee7da..baea924c7f 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -781,7 +781,8 @@ config.action_mailer.smtp_settings = { enable_starttls_auto: true } ``` Note: As of July 15, 2014, Google increased [its security measures](https://support.google.com/accounts/answer/6010255) and now blocks attempts from apps it deems less secure. -You can change your gmail settings [here](https://www.google.com/settings/security/lesssecureapps) to allow the attempts or +You can change your gmail settings [here](https://www.google.com/settings/security/lesssecureapps) to allow the attempts. If your Gmail account has 2-factor authentication enabled, +then you will need to set an [app password](https://myaccount.google.com/apppasswords) and use that instead of your regular password. Alternatively, you can use another ESP to send email by replacing 'smtp.gmail.com' above with the address of your provider. Mailer Testing -- cgit v1.2.3 From 43b09b0c9ccc70f6514c441970d0d0ac03ce525b Mon Sep 17 00:00:00 2001 From: Makoto Nihei Date: Thu, 25 May 2017 04:26:54 +0900 Subject: [ci skip]fix wrong variable name in docs --- 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 d8e85497fa..5c7d1f5365 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1559,7 +1559,7 @@ The `collection.size` method returns the number of objects in the collection. The `collection.find` method finds objects within the collection. It uses the same syntax and options as `ActiveRecord::Base.find`. ```ruby -@available_books = @author.books.find(1) +@available_book = @author.books.find(1) ``` ##### `collection.where(...)` -- cgit v1.2.3 From c7dd4a7a9f20216091399a30a9750a8cf598798e Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 24 May 2017 19:40:00 -0400 Subject: Capitalize Gmail `gmail` --> `Gmail` [ci skip] --- guides/source/action_mailer_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index baea924c7f..7751ac00df 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -781,7 +781,7 @@ config.action_mailer.smtp_settings = { enable_starttls_auto: true } ``` Note: As of July 15, 2014, Google increased [its security measures](https://support.google.com/accounts/answer/6010255) and now blocks attempts from apps it deems less secure. -You can change your gmail settings [here](https://www.google.com/settings/security/lesssecureapps) to allow the attempts. If your Gmail account has 2-factor authentication enabled, +You can change your Gmail settings [here](https://www.google.com/settings/security/lesssecureapps) to allow the attempts. If your Gmail account has 2-factor authentication enabled, then you will need to set an [app password](https://myaccount.google.com/apppasswords) and use that instead of your regular password. Alternatively, you can use another ESP to send email by replacing 'smtp.gmail.com' above with the address of your provider. -- cgit v1.2.3 From af41b98577a09c9177b0fae76b7d07d787d02ce3 Mon Sep 17 00:00:00 2001 From: Krzysztof Maicher Date: Thu, 25 May 2017 14:34:50 +0200 Subject: Add ActiveRecord::Relation#or description to guides [ci skip] --- guides/source/active_record_querying.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 26d01d4ede..d1cbe506b4 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -557,6 +557,19 @@ In other words, this query can be generated by calling `where` with no argument, SELECT * FROM clients WHERE (clients.locked != 1) ``` +### OR Conditions + +`OR` condition between two relations can be build by calling `or` on the first relation +and passing the second one as an argument. + +```ruby +Client.where(locked: true).or(Client.where(orders_count: [1,3,5])) +``` + +```sql +SELECT * FROM clients WHERE (clients.locked = 1 OR clients.orders_count IN (1,3,5)) +``` + Ordering -------- -- cgit v1.2.3 From 9980709c5aa25af7c0fd598bade23c2a9e66efc5 Mon Sep 17 00:00:00 2001 From: Makoto Nihei Date: Sat, 27 May 2017 11:52:18 +0900 Subject: [ci skip]fix wrong variable name in docs --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index d1cbe506b4..07950c6066 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -118,7 +118,7 @@ You can also use this method to query for multiple objects. Call the `find` meth ```ruby # Find the clients with primary keys 1 and 10. -client = Client.find([1, 10]) # Or even Client.find(1, 10) +clients = Client.find([1, 10]) # Or even Client.find(1, 10) # => [#, #] ``` -- cgit v1.2.3 From 7cceb729e64b8eef028dab042b79d8def0730372 Mon Sep 17 00:00:00 2001 From: Makoto Nihei Date: Sat, 27 May 2017 12:03:57 +0900 Subject: [ci skip]fix wrong variable name in docs --- guides/source/active_record_querying.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index d1cbe506b4..412ad0b006 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -150,7 +150,7 @@ The `take` method returns `nil` if no record is found and no exception will be r You can pass in a numerical argument to the `take` method to return up to that number of results. For example ```ruby -client = Client.take(2) +clients = Client.take(2) # => [ # #, # # @@ -189,7 +189,7 @@ If your [default scope](active_record_querying.html#applying-a-default-scope) co You can pass in a numerical argument to the `first` method to return up to that number of results. For example ```ruby -client = Client.first(3) +clients = Client.first(3) # => [ # #, # #, @@ -240,7 +240,7 @@ If your [default scope](active_record_querying.html#applying-a-default-scope) co You can pass in a numerical argument to the `last` method to return up to that number of results. For example ```ruby -client = Client.last(3) +clients = Client.last(3) # => [ # #, # #, -- cgit v1.2.3 From 3b2e3f01488581d9e153dcb6b8ef333bda370aa0 Mon Sep 17 00:00:00 2001 From: Christoph Lupprich Date: Sun, 28 May 2017 16:24:43 +0200 Subject: Remove mentions of deprecated callbacks on ActionDispatch::Callbacks ActionDispatch::Callbacks.to_prepare was removed in #27587 [ci skip] --- guides/source/configuring.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index bf9456a482..aced401bca 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -493,8 +493,6 @@ encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. * `ActionDispatch::Callbacks.before` takes a block of code to run before the request. -* `ActionDispatch::Callbacks.to_prepare` takes a block to run after `ActionDispatch::Callbacks.before`, but before the request. Runs for every request in `development` mode, but only once for `production` or environments with `cache_classes` set to `true`. - * `ActionDispatch::Callbacks.after` takes a block of code to run after the request. ### Configuring Action View @@ -1188,7 +1186,7 @@ Below is a comprehensive list of all the initializers found in Rails in the orde * `finisher_hook`: Provides a hook for after the initialization of process of the application is complete, as well as running all the `config.after_initialize` blocks for the application, railties and engines. -* `set_routes_reloader_hook`: Configures Action Dispatch to reload the routes file using `ActionDispatch::Callbacks.to_prepare`. +* `set_routes_reloader_hook`: Configures Action Dispatch to reload the routes file using `ActiveSupport::Callbacks.to_run`. * `disable_dependency_loading`: Disables the automatic dependency loading if the `config.eager_load` is set to `true`. -- cgit v1.2.3 From 9bd7881c2047f59b42f325ed882068cc881cbe48 Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Mon, 29 May 2017 13:12:48 +0300 Subject: List assert_{,no_}changes in the testing guide This lists the `assert_changes` and `assert_no_changes` methods in the guides. [ci skip] --- guides/source/testing.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index c0394f927e..1db48ed56c 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -350,6 +350,8 @@ Rails adds some custom assertions of its own to the `minitest` framework: | --------------------------------------------------------------------------------- | ------- | | [`assert_difference(expressions, difference = 1, message = nil) {...}`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference) | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.| | [`assert_no_difference(expressions, message = nil, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference) | Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.| +| [`assert_changes(expressions, message = nil, from:, to:, &block) {...}`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes) | Test that the result of evaluating an expression is changed after invoking the passed in block.| +| [`assert_no_changes(expressions, message = nil, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes) | Test the result of evaluating an expression is not changed after invoking the passed in block.| | [`assert_nothing_raised { block }`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_nothing_raised) | Ensures that the given block doesn't raise any exceptions.| | [`assert_recognizes(expected_options, path, extras={}, message=nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes) | Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.| | [`assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_generates) | Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.| -- cgit v1.2.3 From e40c7031844d81379dd7fb530e52156b97df0f9c Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 30 May 2017 05:20:58 +0900 Subject: Remove extra block for `assert_changes` [ci skip] --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 1db48ed56c..e4fc8c7b6e 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -350,7 +350,7 @@ Rails adds some custom assertions of its own to the `minitest` framework: | --------------------------------------------------------------------------------- | ------- | | [`assert_difference(expressions, difference = 1, message = nil) {...}`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference) | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.| | [`assert_no_difference(expressions, message = nil, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference) | Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.| -| [`assert_changes(expressions, message = nil, from:, to:, &block) {...}`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes) | Test that the result of evaluating an expression is changed after invoking the passed in block.| +| [`assert_changes(expressions, message = nil, from:, to:, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes) | Test that the result of evaluating an expression is changed after invoking the passed in block.| | [`assert_no_changes(expressions, message = nil, &block)`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes) | Test the result of evaluating an expression is not changed after invoking the passed in block.| | [`assert_nothing_raised { block }`](http://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_nothing_raised) | Ensures that the given block doesn't raise any exceptions.| | [`assert_recognizes(expected_options, path, extras={}, message=nil)`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes) | Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.| -- cgit v1.2.3 From 980ac58a51a1af0e2acdce0212ad64245929c181 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 29 May 2017 19:56:22 -0400 Subject: Grammar fixes [ci skip] --- guides/source/active_record_querying.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index aea7515974..3676462788 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -559,8 +559,8 @@ SELECT * FROM clients WHERE (clients.locked != 1) ### OR Conditions -`OR` condition between two relations can be build by calling `or` on the first relation -and passing the second one as an argument. +`OR` conditions between two relations can be built by calling `or` on the first +relation, and passing the second one as an argument. ```ruby Client.where(locked: true).or(Client.where(orders_count: [1,3,5])) -- cgit v1.2.3 From 6cc153959ac04a39d4081a2cf23e1ff83c4efe3b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 30 May 2017 09:14:00 -0400 Subject: Replace therubyracer with mini_racer --- guides/source/asset_pipeline.md | 2 +- guides/source/getting_started.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'guides') diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 61b7112247..22b6b278d7 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -868,7 +868,7 @@ pre-existing JavaScript runtimes, you may want to add one to your Gemfile: ```ruby group :production do - gem 'therubyracer' + gem 'mini_racer' end ``` diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 5553f08456..21bd4a3d7a 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -208,7 +208,7 @@ TIP: Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime available on your system, in the absence of a runtime you will see an `execjs` error during asset compilation. Usually macOS and Windows come with a JavaScript runtime installed. -Rails adds the `therubyracer` gem to the generated `Gemfile` in a +Rails adds the `mini_racer` gem to the generated `Gemfile` in a commented line for new apps and you can uncomment if you need it. `therubyrhino` is the recommended runtime for JRuby users and is added by default to the `Gemfile` in apps generated under JRuby. You can investigate -- cgit v1.2.3 From d49866a8d0ae9069d4c875a979de50a61f2ad663 Mon Sep 17 00:00:00 2001 From: Dzianis Dashkevich Date: Thu, 1 Jun 2017 20:48:15 +0300 Subject: Fix articles layout in guides by eliminating W3C validator warnings [ci skip] --- guides/source/getting_started.md | 1 + 1 file changed, 1 insertion(+) (limited to 'guides') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 21bd4a3d7a..6a3a5e465f 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -910,6 +910,7 @@ And then finally, add the view for this action, located at Title Text + <% @articles.each do |article| %> -- cgit v1.2.3 From e42365e129c42bfb60b2960881a1f0c97bd897f0 Mon Sep 17 00:00:00 2001 From: Dzianis Dashkevich Date: Thu, 1 Jun 2017 22:07:31 +0300 Subject: Replace an outdated mention of `jquery_ujs` with `rails-ujs` [ci skip] --- 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 6a3a5e465f..49c691c841 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1490,14 +1490,14 @@ second argument, and then the options as another argument. The `method: :delete` and `data: { confirm: 'Are you sure?' }` options are used as HTML5 attributes so that when the link is clicked, Rails will first show a confirm dialog to the user, and then submit the link with method `delete`. This is done via the -JavaScript file `jquery_ujs` which is automatically included in your +JavaScript file `rails-ujs` which is automatically included in your application's layout (`app/views/layouts/application.html.erb`) when you generated the application. Without this file, the confirmation dialog box won't appear. ![Confirm Dialog](images/getting_started/confirm_dialog.png) -TIP: Learn more about jQuery Unobtrusive Adapter (jQuery UJS) on +TIP: Learn more about Unobtrusive JavaScript on [Working With JavaScript in Rails](working_with_javascript_in_rails.html) guide. Congratulations, you can now create, show, list, update and destroy -- 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 From ec4a836919c021c0a5cf9ebeebb4db5e02104a55 Mon Sep 17 00:00:00 2001 From: Lisa Ugray Date: Mon, 10 Jul 2017 11:12:45 -0400 Subject: Protect from forgery by default Rather than protecting from forgery in the generated ApplicationController, add it to ActionController::Base by config. This configuration defaults to false to support older versions which have removed it from their ApplicationController, but is set to true for Rails 5.2. --- guides/source/configuring.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 21b3ca0efa..28ceef9740 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -401,6 +401,8 @@ The schema dumper adds one additional configuration option: * `config.action_controller.per_form_csrf_tokens` configures whether CSRF tokens are only valid for the method/action they were generated for. +* `config.action_controller.default_protect_from_forgery` determines whether forgery protection is added on `ActionController:Base`. This is false by default, but enabled when loading defaults for Rails 5.2. + * `config.action_controller.relative_url_root` can be used to tell Rails that you are [deploying to a subdirectory](configuring.html#deploy-to-a-subdirectory-relative-url-root). The default is `ENV['RAILS_RELATIVE_URL_ROOT']`. * `config.action_controller.permit_all_parameters` sets all the parameters for mass assignment to be permitted by default. The default value is `false`. -- cgit v1.2.3 From 57add37382e7f9859f82eda9ddf90ca7704d0c2e Mon Sep 17 00:00:00 2001 From: Yuki Nishijima Date: Tue, 11 Jul 2017 12:54:12 -0400 Subject: Fix english for the rescue_from warning [ci skip] --- guides/source/action_controller_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 22537f960c..7de6542f4a 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -1186,7 +1186,7 @@ class ClientsController < ApplicationController end ``` -WARNING: You shouldn't do `rescue_from Exception` or `rescue_from StandardError` unless you have a particular reason as it will cause serious side-effects (e.g. you won't be able to see exception details and tracebacks during development). +WARNING: Using `rescue_from` with `Exception` or `StandardError` would cause serious side-effects as it prevents Rails from handling exceptions properly. As such, it is not recommended to do so unless there is a strong reason. NOTE: When running in the production environment, all `ActiveRecord::RecordNotFound` errors render the 404 error page. Unless you need -- cgit v1.2.3 From 52e050ed00b023968fecda82f19a858876a7c435 Mon Sep 17 00:00:00 2001 From: Lisa Ugray Date: Thu, 6 Jul 2017 12:59:33 -0400 Subject: Change sqlite3 boolean serialization to use 1 and 0 Abstract boolean serialization has been using 't' and 'f', with MySQL overriding that to use 1 and 0. This has the advantage that SQLite natively recognizes 1 and 0 as true and false, but does not natively recognize 't' and 'f'. This change in serialization requires a migration of stored boolean data for SQLite databases, so it's implemented behind a configuration flag whose default false value is deprecated. The flag itself can be deprecated in a future version of Rails. While loaded models will give the correct result for boolean columns without migrating old data, where() clauses will interact incorrectly with old data. While working in this area, also change the abstract adapter to use `"TRUE"` and `"FALSE"` as quoted values and `true` and `false` for unquoted. These are supported by PostreSQL, and MySQL remains overriden. --- guides/source/configuring.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'guides') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 28ceef9740..d7fa8813b2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -375,6 +375,28 @@ The MySQL adapter adds one additional configuration option: * `ActiveRecord::ConnectionAdapters::Mysql2Adapter.emulate_booleans` controls whether Active Record will consider all `tinyint(1)` columns as booleans. Defaults to `true`. +The SQLite3Adapter adapter adds one additional configuration option: + +* `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer` +indicates whether boolean values are stored in sqlite3 databases as 1 and 0 or +'t' and 'f'. Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer` +set to false is deprecated. SQLite databases have used 't' and 'f' to serialize +boolean values and must have old data converted to 1 and 0 (its native boolean +serialization) before setting this flag to true. Conversion can be accomplished +by setting up a rake task which runs + + ```ruby + ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1) + ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 0) + ``` + + for all models and all boolean columns, after which the flag must be set to true +by adding the following to your application.rb file: + + ```ruby + ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true + ``` + The schema dumper adds one additional configuration option: * `ActiveRecord::SchemaDumper.ignore_tables` accepts an array of tables that should _not_ be included in any generated schema file. This setting is ignored unless `config.active_record.schema_format == :ruby`. -- cgit v1.2.3 From 90bb874ea15a16d3fa363a6f5b2fe7302c913f7b Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 13 Jul 2017 07:36:40 +0900 Subject: Fix boolean column migration script --- 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 d7fa8813b2..bc8df5a797 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -387,7 +387,7 @@ by setting up a rake task which runs ```ruby ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1) - ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 0) + ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0) ``` for all models and all boolean columns, after which the flag must be set to true -- cgit v1.2.3 From 17170cea436c3020bb4a9a6a80b5748288081827 Mon Sep 17 00:00:00 2001 From: willnet Date: Fri, 14 Jul 2017 10:01:55 +0900 Subject: [ci skip]Remove options of javascript_link_tag and stylesheet_link_tag in guides --- guides/source/action_view_overview.md | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'guides') diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 10412128cc..e5f4e0ec30 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -464,25 +464,6 @@ Returns an HTML script tag for each of the sources provided. You can pass in the javascript_include_tag "common" # => ``` -If the application does not use the asset pipeline, to include the jQuery JavaScript library in your application, pass `:defaults` as the source. When using `:defaults`, if an `application.js` file exists in your `app/assets/javascripts` directory, it will be included as well. - -```ruby -javascript_include_tag :defaults -``` - -You can also include all JavaScript files in the `app/assets/javascripts` directory using `:all` as the source. - -```ruby -javascript_include_tag :all -``` - -You can also cache multiple JavaScript files into one file, which requires less HTTP connections to download and can better be compressed by gzip (leading to faster transfers). Caching will only happen if `ActionController::Base.perform_caching` is set to true (which is the case by default for the Rails production environment, but not for the development environment). - -```ruby -javascript_include_tag :all, cache: true # => - -``` - #### javascript_path Computes the path to a JavaScript asset in the `app/assets/javascripts` directory. If the source filename has no extension, `.js` will be appended. Full paths from the document root will be passed through. Used internally by `javascript_include_tag` to build the script path. @@ -507,19 +488,6 @@ Returns a stylesheet link tag for the sources specified as arguments. If you don stylesheet_link_tag "application" # => ``` -You can also include all styles in the stylesheet directory using `:all` as the source: - -```ruby -stylesheet_link_tag :all -``` - -You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching is set to true (which is the case by default for the Rails production environment, but not for the development environment). - -```ruby -stylesheet_link_tag :all, cache: true -# => -``` - #### stylesheet_path Computes the path to a stylesheet asset in the `app/assets/stylesheets` directory. If the source filename has no extension, `.css` will be appended. Full paths from the document root will be passed through. Used internally by stylesheet_link_tag to build the stylesheet path. -- cgit v1.2.3 From b47da9814a7eda7c8700614886e18ee89ec1d9e2 Mon Sep 17 00:00:00 2001 From: Emma Barnes Date: Sat, 15 Jul 2017 16:40:41 +0100 Subject: Remove redundant instances of the word 'simply' from documentation, on the basis that if it was simple, the user wouldn't be reading the docs --- guides/source/testing.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides') diff --git a/guides/source/testing.md b/guides/source/testing.md index 7abf3af187..f71e963716 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -18,7 +18,7 @@ Why Write Tests for your Rails Applications? Rails makes it super easy to write your tests. It starts by producing skeleton test code while you are creating your models and controllers. -By simply running your Rails tests you can ensure your code adheres to the desired functionality even after some major code refactoring. +By running your Rails tests you can ensure your code adheres to the desired functionality even after some major code refactoring. Rails tests can also simulate browser requests and thus you can test your application's response without having to test it through your browser. @@ -273,7 +273,7 @@ When a test fails you are presented with the corresponding backtrace. By default Rails filters that backtrace and will only print lines relevant to your application. This eliminates the framework noise and helps to focus on your code. However there are situations when you want to see the full -backtrace. Simply set the `-b` (or `--backtrace`) argument to enable this behavior: +backtrace. Set the `-b` (or `--backtrace`) argument to enable this behavior: ```bash $ bin/rails test -b test/models/article_test.rb @@ -516,7 +516,7 @@ steve: Each fixture is given a name followed by an indented list of colon-separated key/value pairs. Records are typically separated by a blank line. You can place comments in a fixture file by using the # character in the first column. -If you are working with [associations](/association_basics.html), you can simply +If you are working with [associations](/association_basics.html), you can define a reference node between two different fixtures. Here's an example with a `belongs_to`/`has_many` association: @@ -641,7 +641,7 @@ When you generate a new application or scaffold, an `application_system_test_cas is created in the test directory. This is where all the configuration for your system tests should live. -If you want to change the default settings you can simply change what the system +If you want to change the default settings you can change what the system tests are "driven by". Say you want to change the driver from Selenium to Poltergeist. First add the `poltergeist` gem to your Gemfile. Then in your `application_system_test_case.rb` file do the following: -- cgit v1.2.3 From a18cf23a9cbcbeed61e8049442640c7153e0a8fb Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Fri, 14 Jul 2017 08:01:49 +0900 Subject: Set `represent_boolean_as_integer` via `configuration` --- 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 bc8df5a797..61c4bd1e61 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -394,7 +394,7 @@ by setting up a rake task which runs by adding the following to your application.rb file: ```ruby - ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true + Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true ``` The schema dumper adds one additional configuration option: -- cgit v1.2.3 From 3a900a4e36761599661cb5993a9101f50b43bd1c Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 16 Jul 2017 23:29:23 +0900 Subject: Replace Erubis with Erubi in a part of guide [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 86aea2c24d..ccad10f07d 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -109,7 +109,7 @@ A standard Rails application depends on several gems, specifically: * arel * builder * bundler -* erubis +* erubi * i18n * mail * mime-types -- cgit v1.2.3