We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
rails changelog
Welcome to the latest update! We've made some significant improvements and fixes to enhance performance, streamline processes, and ensure better reliability. Here's a rundown of what's new and improved:
๐ New Features & Improvements
-
Memory Optimization in Active Record Models: We've removed the unnecessary casting of
stale_state
to a string to reduce allocations and memory footprint. This change is based on a benchmark that showed a significant number of numeric strings being created, leading to improved memory usage. While this breaks the final assertion of the Rails 6.1 Marshal backward compatibility test, the tradeoff is deemed acceptable for the benefits it brings. -
Simplified
with
Method in ActiveRecord::Relation: TheWithChain
class has been removed, and thewith
method now directly callsspawn.with!(*args)
. This change simplifies the code and removes unnecessary complexity, making the codebase more straightforward and easier to understand. -
Enhanced Debugger Configuration: To prevent runtime overhead and memory bloat, we've added
require: "debug/prelude"
after thedebug
Gemfile entry. This allows users to use breakpoint methods likedebugger
,binding.break
, andbinding.b
without automatically activating the debugger upon requiring the gem. This change aims to improve performance, particularly during CI builds.
๐ Bug Fixes
-
Error Handling in
ActiveRecord::Relation#with
: An error will now be raised when a block is passed to thewith
method. This prevents unexpected behavior and potential bugs, ensuring developers are alerted to incorrect usage and can correct it accordingly. -
Proper Loading of
ActiveSupport::TestCase
: We've fixed an issue whereActiveSupport::TestCase
was being loaded too early in the boot process. The configuration is now wrapped in a load hook, ensuring it gets set at the appropriate time and resolving issues with other engines defining load hooks on:active_support_test_case
. -
Assertion Checks in Tests: We've fixed tests in the framework that were missing assertions. A rescue block was added to handle
ActiveSupport::RaiseWarnings::WarningError
, and a pass statement was added to prevent unnecessary bin files from being generated during app updates. These changes ensure the tests properly check for expected behavior, improving functionality and reliability.
๐งน Chores
- Ignore Tarball from
rake preview_docs
: The tarball file will no longer be included or generated when running this rake command. This change streamlines the preview_docs process, excluding unnecessary files and ensuring a cleaner output.
We hope these updates make your development experience smoother and more efficient. Happy coding! ๐
Included Commits
The commit removes the WithChain class from the codebase and updates the with method in the active_record/relation/query_methods.rb file. Previously, the with method would return a WithChain object if no arguments were provided, but now it directly calls spawn.with!(*args) instead. This change simplifies the code and removes unnecessary complexity by eliminating the WithChain class and directly modifying the relation in place.
Overall, this commit streamlines the with method in ActiveRecord::Relation and removes the WithChain class, making the codebase more straightforward and easier to understand. The with method now directly modifies the relation in place without creating an unnecessary intermediate object, simplifying the logic and improving code readability.
Files changed
- activerecord/lib/active_record/relation/query_methods.rb
This commit removes the unnecessary casting of stale_state
to a string in Active Record models in order to reduce allocations and memory footprint. The decision was based on a benchmark that showed a significant number of numeric strings being created from stale_state
. The commit author tracked the casting all the way back to a previous commit but found no explanation for its addition, leading them to believe it was not needed. The benchmark used to identify the issue involved loading 100 posts with 20 comments each, showing a reduction in memory allocation after the change.
The removal of the casting of stale_state
to a string is expected to improve memory usage and reduce unnecessary allocations in Active Record models. While this change may break the final assertion of the Rails 6.1 Marshal backward compatibility test, the author considers it an acceptable tradeoff for the benefits it brings in terms of memory optimization. The commit modifies the belongs_to_association.rb
file by removing the casting of stale_state
to a string, resulting in a reduction in memory usage and allocations within Active Record models.
Files changed
- activerecord/lib/active_record/associations/belongs_to_association.rb
This commit fixes an issue where ActiveSupport::TestCase was being loaded too early in the boot process due to a configuration implemented in a previous commit. This caused problems when other engines defined load hooks on :active_support_test_case as they would be run immediately. The fix involves wrapping the configuration in a load hook so that it is set at the appropriate time, resolving the issue of ActiveSupport::TestCase being loaded prematurely.
Files changed
This commit fixes tests in the framework that were missing assertions. In the file test_without_assertions_test.rb, a rescue block was added to handle ActiveSupport::RaiseWarnings::WarningError. This change ensures that the test now checks for the presence of assertions in the code. Additionally, in the api_app_generator_test.rb file, a pass statement was added in the test_app_update_does_not_generate_unnecessary_bin_files method to prevent unnecessary bin files from being generated during app updates.
Overall, these changes address the issue of tests lacking assertions in the framework, ensuring that the tests now properly check for the expected behavior in the code. The addition of the rescue block and pass statement help improve the functionality and reliability of the tests in the framework.
Files changed
- activesupport/test/testing/test_without_assertions_test.rb
- railties/test/generators/api_app_generator_test.rb
This commit raises an error when a block is passed to ActiveRecord::Relation#with
method. The reason for this change is to prevent unexpected behavior and potential bugs that may arise from passing a block to this method. By raising an error, developers are alerted to the incorrect usage of the method and can correct it accordingly. This change aims to improve the overall reliability and maintainability of the codebase by enforcing proper usage of the with
method in ActiveRecord::Relation.
Overall, this commit enhances the clarity and consistency of the code by enforcing best practices when using the with
method in ActiveRecord::Relation. It helps to prevent potential errors and unintended consequences that may occur when passing a block to this method. By raising an error in such cases, developers are prompted to review and correct their code, ultimately leading to a more robust and reliable application.
Files changed
This commit addresses an issue identified in the debug gem, where requiring it automatically activates it, potentially causing runtime overhead and memory bloat. To prevent users from being taxed unnecessarily, the proposal is to add require: "debug/prelude"
after the debug Gemfile entry in the default Gemfile template. This change allows users to still use breakpoint methods like debugger
, binding.break
, and binding.b
, but the debugger will only be activated when a breakpoint is hit, rather than automatically upon requiring the gem. This adjustment aims to improve performance and reduce unnecessary burden on users, particularly during CI builds.
Files changed
This commit involves ignoring the tarball from the rake preview_docs command. This means that the tarball file will not be included or generated when running this rake command. This change was likely made to streamline the preview_docs process and exclude unnecessary files from being created during the execution of this command. By ignoring the tarball, the focus can be solely on generating the preview documentation without any additional files cluttering the output.
Overall, this commit simplifies the preview_docs process by excluding the tarball file. This adjustment likely improves the efficiency and cleanliness of the documentation generation, ensuring that only essential files are included in the output. By making this change, the rake preview_docs command can now run more smoothly and effectively without the unnecessary inclusion of the tarball.