To ease reading the "Active Support Core Extensions" guide, let's
automatically link references to Ruby files.
It's also possible to reference other components' files in the even
though it's not used in the guides at the moment.
[Petr Skocik & Robin Dupret]
To make sure that the user won't look at a feature that doesn't
already exist if they are looking at a previous version of the guides,
let's automatically inject the Rails version the guides have been
generated against.
The guide contains a typo in the "local_assigns" section, where
rendering a model named 'Article' via `render @articles` is shown to
render a partial called `_articles.html.erb`, when in fact the necessary
partial name is `_article.html.erb`
Since `Thor::HELP_MAPPINGS` contains `-D`, so `bin/rails -D` show
rails's help. But, in Rails 5.0.1, `bin/rails -D` show the description
of rake task. I think that it is better to have the same behavior.
The exact inspect output of a BigDecimal is out of scope for what we're trying
to communicate about `dup` and `duplicable?` here.
Adding two examples distracts is disctracting, so keep the docs from before
since our minimal version is Ruby 2.2.2.
[ Koichi ITO, Jon Moss, Kasper Timm Hansen ]
This reverts commit 2163874ded, reversing
changes made to 46fdbc5290.
ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true
Duration parsing made independent from any moment of time:
Fixed length in seconds is assigned to each duration part during parsing.
Changed duration of months and years in seconds to more accurate and logical:
1. The value of 365.2425 days in Gregorian year is more accurate
as it accounts for every 400th non-leap year.
2. Month's length is bound to year's duration, which makes
sensible comparisons like `12.months == 1.year` to be `true`
and nonsensical ones like `30.days == 1.month` to be `false`.
Calculations on times and dates with durations shouldn't be affected as
duration's numeric value isn't used in calculations, only parts are used.
Methods on `Numeric` like `2.days` now use these predefined durations
to avoid duplicating of duration constants through the codebase and
eliminate creation of intermediate durations.
Rails automatically finds bi-directional associations between models
with well-named associations. However, when using non-standard naming,
you have to use :inverse_of to explicitly tell Rails about the bi-
directional association.
With reference to #27516
[ci skip]
When I was looking for how to default the entire routes file to JSON I could only find the postfix option. It was mentioned on IRC that you could do this with a block as well and I had not found it in the documentation.
- Mentioned clearly that for PostgreSQL < 9.4, you need to pass the
default option with "uuid_generate_v4()"
- Also updated PostgreSQL Active Record guide with this change.
- https://github.com/rails/rails/pull/25395#r66877078
The first release note entry mentioned #on_weekday?, but that was only
added by the second PR mentioned there. To simplify reading the notes
just merge the two, since they are related methods. [ci skip]
The hashes returned in some examples of the following sections had items in a different order than their receivers. That may mislead readers into believing those methods will not preserve element order.
Extensions to Hash/Working with Keys/transform_keys and transform_keys!
Extensions to Hash/Working with Keys/stringify_keys and stringify_keys!
Extensions to Hash/Working with Keys/symbolize_keys and symbolize_keys!
Extensions to Hash/Slicing
This replaces boilerplate in the “benchmark your code” section of the
contributors’ guide with an executable template. I also amended the text
to encourage best practices and codified it in the template.
For now this is only good for relatively self-contained changes that can
be inlined into a simple script. In the future, this can be expanded to
cover how to measure the difference between two commits.
The output looks like this:
```
==================================== Empty =====================================
Warming up --------------------------------------
blank? 225.963k i/100ms
fast_blank? 238.147k i/100ms
Calculating -------------------------------------
blank? 8.825M (± 6.4%) i/s - 44.063M in 5.014824s
fast_blank? 9.311M (± 6.3%) i/s - 46.439M in 5.009153s
Comparison:
fast_blank?: 9310694.8 i/s
blank?: 8824801.7 i/s - same-ish: difference falls within error
================================= Single Space =================================
Warming up --------------------------------------
blank? 56.581k i/100ms
fast_blank? 232.774k i/100ms
Calculating -------------------------------------
blank? 813.985k (±16.7%) i/s - 4.017M in 5.076576s
fast_blank? 9.547M (± 5.2%) i/s - 47.719M in 5.013204s
Comparison:
fast_blank?: 9547414.0 i/s
blank?: 813985.0 i/s - 11.73x slower
================================== Two Spaces ==================================
Warming up --------------------------------------
blank? 58.265k i/100ms
fast_blank? 244.056k i/100ms
Calculating -------------------------------------
blank? 823.343k (±16.2%) i/s - 4.020M in 5.014213s
fast_blank? 9.484M (± 4.9%) i/s - 47.347M in 5.005339s
Comparison:
fast_blank?: 9484021.6 i/s
blank?: 823343.1 i/s - 11.52x slower
=============================== Mixed Whitspaces ===============================
Warming up --------------------------------------
blank? 53.919k i/100ms
fast_blank? 237.103k i/100ms
Calculating -------------------------------------
blank? 763.435k (±16.8%) i/s - 3.720M in 5.018029s
fast_blank? 9.672M (± 5.8%) i/s - 48.369M in 5.019356s
Comparison:
fast_blank?: 9672467.2 i/s
blank?: 763435.4 i/s - 12.67x slower
=============================== Very Long String ===============================
Warming up --------------------------------------
blank? 34.037k i/100ms
fast_blank? 240.366k i/100ms
Calculating -------------------------------------
blank? 409.731k (± 8.9%) i/s - 2.042M in 5.028235s
fast_blank? 9.794M (± 4.3%) i/s - 49.035M in 5.016328s
Comparison:
fast_blank?: 9794225.2 i/s
blank?: 409731.4 i/s - 23.90x slower
```
ActionDispatch::ParamsParser class was removed in favor of
ActionDispatch::Http::Parameters so it is better to move the error
constant to the new class.
When the initial evented monitor feature was written, the latest version of listen
was the 3.0.x series. Since then the listen project has moved on to the 3.1.x series.
This patch allows the use of the new versions.
Currently mongrel is not maintained.
And it couldn't be built with any Ruby versions that
supported by Rails.
It is reasonable to remove the word "mongrel" in order to avoid
confusion from newcomer.
07d3d40 changed how exceptions are handled in after_commit
and after_destroy callbacks. This commit updates the 5.0
release notes and the ActiveRecord callback guide to reflect
the new behavior.
[ci skip]
section [ci skip]
- Method `assert_nothing_raised` is Rails' own custom assertion method and
not a part of Minitest. So move it from Minitest assertions section to Rails
Specific Assertions section.
Action Cable's test `test/subscription_adapter/redis_test.rb` fail if
Redis is not installed and running.
Following the guides `development_dependen there's no mention to this.
* Added location for route, view and job tests to section 2.1. (They are currently only defined in sections 8 Testing Views and 11 Testing Jobs.)
* Added location for route test in section 7 Testing Routes. (Currently only defined in section 8 Testing Views.)
Fixes#25744 by slightly increasing the margin in code syntax
highlights. With a margin of 0, it was cutting off underscores in Linux
browesers, so I slightly increased it to 0.5px.
Listening to a few developers today discussing their troubles in understanding how to use the asset pipeline, it turns out that the precompile examples in the guides and assets.rb template have over time become a bit inconsistent.
This PR makes the examples consistent in code style, spacing, and asset names, removes the old 'swfObject.js' example, and in a couple of places wraps lines at 80 characters including in the assets.rb template.
Re-add spaces inside array parentheses.
When you don't explicitly provide `optional: true` to a `belongs_to`
definition, rails adds a validation to ensure presence of the
`belongs_to` validation.
However, when the validation is added, it is added with a message key of
`:required`, which was not documented in the "Translations for Active
Record Models" section of the i18n guides.
Here are the lines that add the `:required` message:
c3e3577f9d/activerecord/lib/active_record/associations/builder/belongs_to.rb (L136-L138)
This commit adds the "non-optional association" validation to the table,
so rails users know how to override the message for this validation. The
default message is "must exist".
I've noticed that once `<h1>Editing article</h1>` L1157 was the title and then later on it's `<h1>Edit article</h1>` L1358 which kind of makes more sense...
[ci skip]
The `increment!` and `decrement!` methods were recently reimplemented to
make them safe to call from multiple connections concurrently. This
changed their behaviour in a few ways.
Previously they used `update_attribute`, which calls the attribute
setter method, runs callbacks, and touches the record. Now they behave
more like `update_column`, writing the update to the database directly
and bypassing all of those steps.
The Guides section about autoloading being disabled was slightly confusing
(#24724) and didn't directly reference the removed feature by name
(config.autoload_paths) making it much harder for someone to search the upgrade
guides for a mention or serendipitously find it via a Google search when running
into autoloading issues.
I also fixed some confusing turns of phrase and a missing word.
/cc @vipulnsward @jvanbaarsen
Implement naive partial caching mechanism.
Add test for LogSubscriber
Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it.
Fixed tests
Remove useless settings
Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute
Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload.
Update test's hash syntax
Add configuration to enable/disable fragment caching logging
Remove unless test and add new test to ensure cache info won't effect next rendering's log
Move :enable_fragment_cache_logging config from ActionView to ActionPack
Apply new config to tests
Update actionview's changelog
Update configuration guide
Improve actionview's changelog
Refactor PartialRenderer#render and log tests
Mute subscriber's log instead of disabling instrumentation.
Fix typo, remove useless comment and use new hash syntax
Improve actionpack's log_subscriber test
Fix rebase mistake
Apply new config to all caching intstrument actions
Due to the limited support for inotify (Microsoft/BashOnWindows#216) in
WSL the best thing to do at moment is add a note about skipping spring
and listen when generating your application in the Getting Started guide.
[skip ci]
Fixes#26054.
Code like `render(topics) => render("topics/topic")` adds confusion
for the readers. On first impression, that code feels like hash kind
of data, but it's not. So make it more clear and meaningful.
- By default the session store will be set to cookie store with
application name as session key.
- Older apps are not affected as they will have the session store
initializer generated by Rails in older versions, and Rails will not
overwrite the session store if it is already set or disabled.
- But new apps will not have the initializer, instead the session store
will be set to cookie store by default.
- Based on comment by DHH here - https://github.com/rails/rails/issues/25181#issuecomment-222312764.
In #23179 the migration generator was changed to no longer output `index: true` for `references` migrations. This updates the migrations guide to remove `index: true` from relevant examples.
[ci skip]
The most complete list of field types appears in the `SchemaStatements` docs rather than the `TableDefinition` docs.
The change to link to `SchemaStatements` means that the explanation for the `index` parameter is no longer available on the linked-to page. A brief explanation of the `index` parameter is added directly in the guide to make up for this.