aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
Diffstat (limited to 'guides')
-rw-r--r--guides/source/4_2_release_notes.md7
-rw-r--r--guides/source/action_controller_overview.md4
-rw-r--r--guides/source/active_job_basics.md25
-rw-r--r--guides/source/active_record_basics.md2
-rw-r--r--guides/source/active_record_migrations.md2
-rw-r--r--guides/source/active_record_validations.md6
-rw-r--r--guides/source/active_support_core_extensions.md16
-rw-r--r--guides/source/active_support_instrumentation.md2
-rw-r--r--guides/source/configuring.md29
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md2
-rw-r--r--guides/source/credits.html.erb2
-rw-r--r--guides/source/upgrading_ruby_on_rails.md6
12 files changed, 69 insertions, 34 deletions
diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md
index a598c7c319..d9f49aac55 100644
--- a/guides/source/4_2_release_notes.md
+++ b/guides/source/4_2_release_notes.md
@@ -395,6 +395,9 @@ Please refer to the [Changelog][action-pack] for detailed changes.
### Deprecations
+* Deprecated the `only_path` option on `*_path` helpers.
+ ([Commit](https://github.com/rails/rails/commit/aa1fadd48fb40dd9396a383696134a259aa59db9))
+
* Deprecated `assert_tag`, `assert_no_tag`, `find_tag` and `find_all_tag` in
favor of `assert_select`.
([Commit](https://github.com/rails/rails-dom-testing/commit/b12850bc5ff23ba4b599bf2770874dd4f11bf750))
@@ -750,6 +753,10 @@ Please refer to the [Changelog][active-support] for detailed changes.
### Notable changes
+* `Object#try` and `Object#try!` can now be used without an explicit receiver.
+ ([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
+ [Pull Request](https://github.com/rails/rails/pull/17361))
+
* Introduced new configuration option `active_support.test_order` for
specifying the order test cases are executed. This option currently defaults
to `:sorted` but will be changed to `:random` in Rails 5.0.
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index ca1e79d3ce..8890ea453e 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -1221,7 +1221,9 @@ Create the controller and views.
error.html.erb
```
-Do not forget to set the correct status code on the controller as shown before. You should avoid using the database or any complex operations because the user is already on the error page. Generating another error while on an error page could cause issues.
+Do not forget to set the correct status code on the controller as shown before.
+
+WARNING: You should avoid using the database or any complex operations because the user is already on the error page. Generating another error while on an error page could cause issues like presenting an empty page for the users.
Force HTTPS protocol
--------------------
diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md
index 9c34418fab..875919e237 100644
--- a/guides/source/active_job_basics.md
+++ b/guides/source/active_job_basics.md
@@ -149,6 +149,29 @@ end
# environment
```
+The default queue name prefix delimiter is '_'. This can be changed by setting
+`config.active_job.queue_name_delimiter` in `application.rb`:
+
+```ruby
+# config/application.rb
+module YourApp
+ class Application < Rails::Application
+ config.active_job.queue_name_prefix = Rails.env
+ config.active_job.queue_name_delimiter = '.'
+ end
+end
+
+# app/jobs/guests_cleanup.rb
+class GuestsCleanupJob < ActiveJob::Base
+ queue_as :low_priority
+ #....
+end
+
+# Now your job will run on queue production.low_priority on your
+# production environment and on staging.low_priority on your staging
+# environment
+```
+
If you want more control on what queue a job will be run you can pass a :queue
option to #set:
@@ -263,7 +286,7 @@ class TrashableCleanupJob
end
```
-This works with any class that mixes in `ActiveModel::GlobalIdentification`, which
+This works with any class that mixes in `GlobalID::Identification`, which
by default has been mixed into Active Model classes.
diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md
index ecf3483d7e..bd074d0055 100644
--- a/guides/source/active_record_basics.md
+++ b/guides/source/active_record_basics.md
@@ -31,7 +31,7 @@ Object Relational Mapping system.
in his book _Patterns of Enterprise Application Architecture_. In
Active Record, objects carry both persistent data and behavior which
operates on that data. Active Record takes the opinion that ensuring
-data access logic is part of the object will educate users of that
+data access logic as part of the object will educate users of that
object on how to write to and read from the database.
### Object Relational Mapping
diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md
index 229c6ee458..c8a31fe7b8 100644
--- a/guides/source/active_record_migrations.md
+++ b/guides/source/active_record_migrations.md
@@ -466,7 +466,7 @@ add_foreign_key :articles, :authors
```
This adds a new foreign key to the `author_id` column of the `articles`
-table. The key references the `id` column of the `articles` table. If the
+table. The key references the `id` column of the `authors` table. If the
column names can not be derived from the table names, you can use the
`:column` and `:primary_key` options.
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index 4dc7203ba3..6f45ca698d 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -361,6 +361,8 @@ class Product < ActiveRecord::Base
end
```
+Alternatively, you can require that the specified attribute does _not_ match the regular expression by using the `:without` option.
+
The default error message is _"is invalid"_.
### `inclusion`
@@ -425,7 +427,7 @@ class Essay < ActiveRecord::Base
validates :content, length: {
minimum: 300,
maximum: 400,
- tokenizer: lambda { |str| str.scan(/\w+/) },
+ tokenizer: lambda { |str| str.split(/\s+/) },
too_short: "must have at least %{count} words",
too_long: "must have at most %{count} words"
}
@@ -704,7 +706,7 @@ we don't want names and surnames to begin with lower case.
```ruby
class Person < ActiveRecord::Base
validates_each :name, :surname do |record, attr, value|
- record.errors.add(attr, 'must start with upper case') if value =~ /\A[a-z]/
+ record.errors.add(attr, 'must start with upper case') if value =~ /\A[[:lower:]]/
end
end
```
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index de42f13145..f6f96b79c6 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -1833,16 +1833,14 @@ attribute names:
```ruby
def full_messages
- full_messages = []
-
- each do |attribute, messages|
- ...
- attr_name = attribute.to_s.gsub('.', '_').humanize
- attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
- ...
- end
+ map { |attribute, message| full_message(attribute, message) }
+end
- full_messages
+def full_message
+ ...
+ attr_name = attribute.to_s.tr('.', '_').humanize
+ attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
+ ...
end
```
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index 7033947468..83f3645b31 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -135,7 +135,9 @@ Action Controller
| `:format` | html/js/json/xml etc |
| `:method` | HTTP request verb |
| `:path` | Request path |
+| `:status` | HTTP status code |
| `:view_runtime` | Amount spent in view in ms |
+| `:db_runtime` | Amount spent executing database queries in ms |
```ruby
{
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index be0478653b..58c3f217eb 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -368,20 +368,21 @@ encrypted cookies salt value. Defaults to `'signed encrypted cookie'`.
```ruby
config.action_dispatch.rescue_responses = {
- 'ActionController::RoutingError' => :not_found,
- 'AbstractController::ActionNotFound' => :not_found,
- 'ActionController::MethodNotAllowed' => :method_not_allowed,
- 'ActionController::UnknownHttpMethod' => :method_not_allowed,
- 'ActionController::NotImplemented' => :not_implemented,
- 'ActionController::UnknownFormat' => :not_acceptable,
- 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
- 'ActionDispatch::ParamsParser::ParseError' => :bad_request,
- 'ActionController::BadRequest' => :bad_request,
- 'ActionController::ParameterMissing' => :bad_request,
- 'ActiveRecord::RecordNotFound' => :not_found,
- 'ActiveRecord::StaleObjectError' => :conflict,
- 'ActiveRecord::RecordInvalid' => :unprocessable_entity,
- 'ActiveRecord::RecordNotSaved' => :unprocessable_entity
+ 'ActionController::RoutingError' => :not_found,
+ 'AbstractController::ActionNotFound' => :not_found,
+ 'ActionController::MethodNotAllowed' => :method_not_allowed,
+ 'ActionController::UnknownHttpMethod' => :method_not_allowed,
+ 'ActionController::NotImplemented' => :not_implemented,
+ 'ActionController::UnknownFormat' => :not_acceptable,
+ 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
+ 'ActionController::InvalidCrossOriginRequest' => :unprocessable_entity,
+ 'ActionDispatch::ParamsParser::ParseError' => :bad_request,
+ 'ActionController::BadRequest' => :bad_request,
+ 'ActionController::ParameterMissing' => :bad_request,
+ 'ActiveRecord::RecordNotFound' => :not_found,
+ 'ActiveRecord::StaleObjectError' => :conflict,
+ 'ActiveRecord::RecordInvalid' => :unprocessable_entity,
+ 'ActiveRecord::RecordNotSaved' => :unprocessable_entity
}
```
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 302c4ca9c0..4eb360cc7a 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -193,7 +193,7 @@ Now get busy and add/edit code. You're on your branch now, so you can write what
* Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
-TIP: Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Rails will generally not be accepted.
+TIP: Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Rails will generally not be accepted (read more about [our rationales behind this decision](https://github.com/rails/rails/pull/13771#issuecomment-32746700)).
#### Follow the Coding Conventions
diff --git a/guides/source/credits.html.erb b/guides/source/credits.html.erb
index 8767fbecce..61ea0b44ef 100644
--- a/guides/source/credits.html.erb
+++ b/guides/source/credits.html.erb
@@ -40,7 +40,7 @@ Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wi
<% end %>
<%= author('Tore Darell', 'toretore') do %>
- Tore Darell is an independent developer based in Menton, France who specialises in cruft-free web applications using Ruby, Rails and unobtrusive JavaScript. His home on the Internet is his blog <a href="http://tore.darell.no">Sneaky Abstractions</a>.
+ Tore Darell is an independent developer based in Menton, France who specialises in cruft-free web applications using Ruby, Rails and unobtrusive JavaScript. You can follow him on <a href="http://twitter.com/toretore">Twitter</a>.
<% end %>
<%= author('Jeff Dean', 'zilkey') do %>
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 7cc176cdcc..f07dcd04f7 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -177,7 +177,7 @@ after_bundle do
end
```
-### Rails Html Sanitizer
+### Rails HTML Sanitizer
There's a new choice for sanitizing HTML fragments in your applications. The
venerable html-scanner approach is now officially being deprecated in favor of
@@ -200,15 +200,15 @@ Read the [gem's readme](https://github.com/rails/rails-html-sanitizer) for more
The documentation for `PermitScrubber` and `TargetScrubber` explains how you
can gain complete control over when and how elements should be stripped.
-If your application needs to old behaviour include `rails-deprecated_sanitizer` in your Gemfile:
+If your application needs to use the old sanitizer implementation, include `rails-deprecated_sanitizer` in your Gemfile:
```ruby
gem 'rails-deprecated_sanitizer'
```
### Rails DOM Testing
+The [`TagAssertions` module](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/TagAssertions.html) (containing methods such as `assert_tag`), [has been deprecated](https://github.com/rails/rails/blob/6061472b8c310158a2a2e8e9a6b81a1aef6b60fe/actionpack/lib/action_dispatch/testing/assertions/dom.rb) in favor of the `assert_select` methods from the `SelectorAssertions` module, which has been extracted into the [rails-dom-testing gem](https://github.com/rails/rails-dom-testing).
-TODO: Mention https://github.com/rails/rails/commit/4e97d7585a2f4788b9eed98c6cdaf4bb6f2cf5ce
Upgrading from Rails 4.0 to Rails 4.1
-------------------------------------