When using Action Text's rich textarea, it's possible to attach files to the
editor. Previously, that action didn't dispatch any events, which made it hard
to react to the file uploads. For instance, if an upload failed, there was no
way to notify the user about it, or remove the attachment from the editor.
This commits adds new events - `direct-upload:start`, `direct-upload:progress`,
and `direct-upload:end` - similar to how Active Storage's direct uploads work.
Closes#37793
Supersedes #37794
Co-authored-by: Brad Rees <github@bradleyrees.com>
`register_*` seems a more common pattern in Rails, especially for third
party hooks. For example:
Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
Other examples:
ActionMailer::Base.register_preview_interceptor
MimeType.register
MimeType.register_alias
ActiveModel::Type.register
When running tests in parallel, a new database is created for each test
worker (via `ActiveRecord::TestDatabases.create_and_load_schema`). Each
of these databases use different OID numbers for custom defined types
such as enums. If model schemas are loaded before forking -- as done in
`railties/lib/rails/testing/maintain_test_schema.rb` when `eager_load`
is true -- Rails will hold on to the OID numbers from the original
database. Thus each test worker does not recognize the OID numbers when
resolving model attribute types.
This commit sidesteps the problem by resolving model attribute types on
schema load. This does not address the conflicting OID numbers, but
each test worker will inherit properly resolved attribute types.
Fixes#52607.
CodeStatistics and CodeStatisticsCalculator are currenltly top-level
constants, while almost everything in `railties/lib/rails` is namespaced
to `Rails`. These have probably never conflicted with other top-level
constants, but Rails should not pollute the top-level namespace if it's
not necessary.
Previously we added :row_count to the instrumentation payload for
sql.active_record, but only for uncached queries. This adds the same
information on queries which are cached.
If a newline accidentally gets added to the encrypted content file, it
is unable to be decrypted.
Like the key file, this ensures that the content is stripped of newlines
before decryption.
* Revert "Switch back to DelegateClass(ActiveModel::Type::Value)"
This reverts commit 91745df899.
* Revert "Update docs and changelog"
This reverts commit b234a94e56.
* Revert "Nest encrypted attribute types within serialized types"
This reverts commit 6a27e7b2f9.
* Revert "Encryption casting with `encrypts` before `serialize`"
This reverts commit 4dd2b22efe.
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
Here are some of the things addressed from this Guide.
- [X] We mention Rack application right away, good place to link to the [Rack guide](https://edgeguides.rubyonrails.org/rails_on_rack.html).
- [X] Would it make sense to link "CRUD operation" to something like the [AR Basics CRUD](https://edgeguides.rubyonrails.org/active_record_basics.html#crud-reading-and-writing-data) section? We don't _always_ need to tie CRUD to database, it's more about the concept.
- [X] Under Path and URL helpers, it might make sense to turn that list into a table to make it easier to scan?
- [X] Singular resources starts with examples of using get, maybe it should be specific to resource and leave get to Non-Resourceful Routes section? That section doesn't start with "simple" examples.
- [X] "Because you might want to use the same controller for a singular route (/account) and a plural route (/accounts/45), singular resources map to plural controllers." => I've never seen this be the case, I think this can be reworded to explain that singular resources map to plural controllers, without this idea of "use the same controller".
- [X] Under shallow nesting, there's a long example with three child resources to demonstrante that "all get the same shallow behavior"... maybe that'd be better with just 2 so that the table doesn't get so big/long.
- [X] Under creating paths and URLs from objects, it explains how to create paths from objects (i.e. polymorphic routing), that may be a good segway to show that it uses the route key / singular route key from ActiveModel::Naming to figure that out. (could be a note/tip of sorts for example, just thought it'd be good to make that connection somewhere) Also ActiveModel::Conversion#to_param would be used to convert the IDs.
- [X] member and collection are explained under "Adding more RESTful actions", but there's not a good clarification of what the terms represent, i.e. that member refers to routes acting on a single element, much like show/update/destroy, and collection referes to routes acting on multiple (or a collection of) elements like index. Is it worth clarifying further?
- [X] Consider: Constraints could be a main section rather than live under non-resourceful routes, because generally speaking, they can be applied anywhere, even for resources. The only specific one would be match...via:
--> Good point. Tried to move the 3 or 4 sub-sections related to constraints, but couldn't decide where they fit, after non-resource routes or before, and how to transition into them...leaving it as is for now.
- [X] Under Route Globbing and Wildcard Segments there's a waning about passing format: false related to "old 3.0.x behavior" which can either be explained better (what's the meaning of passing format: false), and/or potentially removed (at least the mention to "3.0.x behavior" could be removed)
- [X] When explaining about using draw to break down very large route files, that subsection could be a caution/warning of sorts to call more attention to the fact that most people shouldn't need it.
- [X] We could explain how to check routes via console with Rails.application.routes.url_helpers under inspecting routes.
- [X] Document the somewhat recent `--unused` option to rails routes. ([Reference](https://github.com/rails/rails/pull/51316#issuecomment-1994428608))
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
Co-authored-by: Matheus Richard <matheusrichardt@gmail.com>
Co-authored-by: Bartosz Łęcki <bart.lecki@gmail.com>
Co-authored-by: Lucas Fernandes <lsfernandes92@gmail.com>
Co-authored-by: Ruy Rocha <108208+ruyrocha@users.noreply.github.com>
Co-authored-by: Hrishi Mittal <hrishimittal@gmail.com>
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Reverts #51591 as it is not necessary anymore.
All the Rails currently supported versions (>= 7.1
as of now) support `sqlite3` 2.0, while edge Rails
requires `sqlite3` 2.0 or higher.
`STATS_DIRECTORIES` is used by third parties to add directories to the
statistics output. It's a global constant defined in a Rake file, that
gets loaded anytime the Rake commands get loaded.
For example Rspec Rails adds these in a prepended Rake task:
8c17b4e502/lib/rspec/rails/tasks/rspec.rake (L43)
Rake tasks only get loaded if no matching Thor task has been found. This
means `STATS_DIRECTORIES` is only available when the Rake commands have
loaded.
As the stats command has now been moved to a Thor task, calling
`bin/rails stats` will no longer add directories to `STATS_DIRECTORIES`,
as the Rake commands don't get loaded anymore.
To remove the dependency on Rake and avoid a global constant we can add
an API to add directories: `CodeStatistics.add_directory`.
`STATS_DIRECTORIES` is deprecated.
`deprecate_constant` couldn't be used here as that doesn't seem to work
for the root namespace.
Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
This pull request allows `URI::RFC3986_PARSER` warnings appeared since https://buildkite.com/rails/rails-nightly/builds/931
This warning has been implemented to Ruby master branch via b41d79962a
and the original pull request for URI is https://github.com/ruby/uri/pull/114
We are not able to just replace `URI::DEFAULT_PARSER` with `URI::RFC2396_PARSER`
because `URI::RFC2396_PARSER` gets `uninitialized constant URI::RFC2396_PARSER (NameError)` with Ruby 3.3.4 as reported https://github.com/ruby/uri/issues/118
We can revert this commit and replace `URI::DEFAULT_PARSER` with `URI::RFC2396_PARSER` once `URI::RFC2396_PARSER` is available for uri bundled with Ruby 3.3.4 or older versions.
- This commit allows the warning below and let Rails CI against Ruby master branch run
```
$ RAILS_STRICT_WARNINGS=1 bin/test test/abstract/callbacks_test.rb
/home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:2063: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.
/home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/testing/strict_warnings.rb:35:in 'ActiveSupport::RaiseWarnings#warn': /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:2063: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly. (ActiveSupport::RaiseWarnings::WarningError)
from <internal:warning>:54:in 'Kernel#warn'
from /home/yahonda/.rbenv/versions/trunk/lib/ruby/3.4.0+0/uri/rfc3986_parser.rb:156:in 'URI::RFC3986_Parser#escape'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:2063:in 'ActionDispatch::Routing::Mapper::Resources#add_route'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:2038:in 'ActionDispatch::Routing::Mapper::Resources#decomposed_match'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:2002:in 'block in ActionDispatch::Routing::Mapper::Resources#map_match'
from <internal:array>:53:in 'Array#each'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:1996:in 'ActionDispatch::Routing::Mapper::Resources#map_match'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:1739:in 'ActionDispatch::Routing::Mapper::Resources#match'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:798:in 'ActionDispatch::Routing::Mapper::HttpHelpers#map_method'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/mapper.rb:741:in 'ActionDispatch::Routing::Mapper::HttpHelpers#get'
from /home/yahonda/src/github.com/rails/rails/actionpack/test/abstract_unit.rb:71:in 'block (2 levels) in <top (required)>'
from /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/deprecation/reporting.rb:43:in 'ActiveSupport::Deprecation::Reporting#silence'
from /home/yahonda/src/github.com/rails/rails/actionpack/test/abstract_unit.rb:70:in 'block in <top (required)>'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/route_set.rb:479:in 'BasicObject#instance_exec'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/route_set.rb:479:in 'ActionDispatch::Routing::RouteSet#eval_block'
from /home/yahonda/src/github.com/rails/rails/actionpack/lib/action_dispatch/routing/route_set.rb:461:in 'ActionDispatch::Routing::RouteSet#draw'
from /home/yahonda/src/github.com/rails/rails/actionpack/test/abstract_unit.rb:69:in '<top (required)>'
from /home/yahonda/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'Kernel.require'
from /home/yahonda/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'block (2 levels) in Kernel#replace_require'
from /home/yahonda/src/github.com/rails/rails/actionpack/test/abstract/callbacks_test.rb:3:in '<top (required)>'
from /home/yahonda/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'Kernel.require'
from /home/yahonda/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'block (2 levels) in Kernel#replace_require'
from /home/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:62:in 'block in Rails::TestUnit::Runner.load_tests'
from <internal:array>:53:in 'Array#each'
from /home/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:60:in 'Rails::TestUnit::Runner.load_tests'
from /home/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:52:in 'Rails::TestUnit::Runner.run'
from /home/yahonda/src/github.com/rails/rails/tools/test.rb:18:in '<top (required)>'
from bin/test:5:in 'Kernel#require_relative'
from bin/test:5:in '<main>'
$
```
The CLI tool used as a database interface is now specified and
customisable via ActiveRecord.database_cli.
This specifies the current defaults but allows them to be overridden by
users. It continues to accept array values to allow fallback options.
* Update the description of when SQLite might make sense as the configured database
* Update configuring.md
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
This reverts commit 121e0ad015, reversing
changes made to d68e43922b.
Fixes#52607.
But this reintroduce #49717. Since enum not backed by columns are
less common, we can live with that for now.