1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview
aaron 432698ef2b
Fix SELECT COUNT queries when rendering ActiveRecord collections (#40870)
* Fix `SELECT COUNT` queries when rendering ActiveRecord collections

Fixes #40837

When rendering collections, calling `size` when the collection is an
ActiveRecord relation causes unwanted `SELECT COUNT(*)` queries. This
change ensures the collection is an array before getting the size, and
also loads the relation for any further array inspections.

* Test queries when rendering relation collections

* Add `length` support to partial collection iterator

Allows getting the size of a relation without duplicating records, but
still loads the relation. The length method existence needs to be
checked because you can pass in an `Enumerator`, which does not respond
to `length`.

* Ensure unsubscribed from notifications after tests

[Rafael Mendonça França + aar0nr]
2020-12-18 15:58:11 -05:00
..
app/assets/javascripts Use ES module syntax for application.js.tt and docs 2020-06-16 15:12:12 -04:00
bin
lib Fix SELECT COUNT queries when rendering ActiveRecord collections (#40870) 2020-12-18 15:58:11 -05:00
test Fix SELECT COUNT queries when rendering ActiveRecord collections (#40870) 2020-12-18 15:58:11 -05:00
.gitignore
actionview.gemspec Update the Rails mailing list URLs to new discuss discourse URL [ci skip] 2020-04-02 22:00:28 +05:30
blade.yml
CHANGELOG.md Handle nil translation key 2020-12-10 11:51:32 -06:00
coffeelint.json
MIT-LICENSE Bump license years from 2019 to 2020 [ci skip] 2020-01-01 15:10:31 +05:30
package.json Start Rails 6.2 development 🎉 2020-12-03 01:35:29 +00:00
Rakefile Load framework test files in deterministic order 2019-12-16 16:55:06 +00:00
README.rdoc Update the Rails mailing list URLs to new discuss discourse URL [ci skip] 2020-04-02 22:00:28 +05:30
RUNNING_UJS_TESTS.rdoc
RUNNING_UNIT_TESTS.rdoc

= Action View

Action View is a framework for handling view template lookup and rendering, and provides
view helpers that assist when building HTML forms, Atom feeds and more.
Template formats that Action View handles are ERB (embedded Ruby, typically
used to inline short Ruby snippets inside HTML), and XML Builder.

You can read more about Action View in the {Action View Overview}[https://edgeguides.rubyonrails.org/action_view_overview.html] guide.

== Download and installation

The latest version of Action View can be installed with RubyGems:

  $ gem install actionview

Source code can be downloaded as part of the Rails project on GitHub:

* https://github.com/rails/rails/tree/master/actionview


== License

Action View is released under the MIT license:

* https://opensource.org/licenses/MIT


== Support

API documentation is at

* https://api.rubyonrails.org

Bug reports for the Ruby on Rails project can be filed here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://discuss.rubyonrails.org/c/rubyonrails-core