rails changelog


Here's a delightful update on the latest changes that have been made to enhance your Rails experience. We've got performance improvements, error message clarity, and some essential bug fixes that will make your development life a bit smoother. Let's dive into the details! 🚀

  • Improvement: Streamlined Active Storage Validation 🎉
    For tasks like assets:precompile, we're now skipping the loading of ActiveStorage::Blob. This means less clutter and fewer potential misconfigurations when Active Storage isn't needed. Your precompilation process just got a little bit lighter!

  • Improvement: Clearer Error Messages for Routes 🔍
    When you mess up the :only or :except options in your routes, you'll now see the resource name in the error message. This makes it much easier to pinpoint the source of the problem, especially when dealing with gem-defined routes. No more guessing games!

  • Improvement: Enhanced Notification Testing 🛠️
    assert_notification now matches on a payload subset by default and returns the matched notification. This update makes your notification tests more flexible and informative. Plus, we've tidied up some tests for a cleaner codebase.

  • Bugfix: StringJoin Nodes Compilation Issue Resolved 🐛
    We've stopped eagerly compiling StringJoin nodes, fixing an issue where bind variables were getting lost, leading to broken queries. Your queries should now behave as expected, keeping all those important variables intact.

  • Bugfix: Multibyte Deprecation Warning Avoided 📜
    Say goodbye to pesky deprecation warnings when quoting multibyte characters. We've adjusted the quoting mechanism to handle ActiveSupport::Multibyte::Chars without triggering any warnings, ensuring a smoother development experience.

  • Bugfix: Improved Template Rendering Error Handling 🎨
    Argument errors in templates are now handled with more precision. If it's about strict locals, you'll get a specific ActionView::StrictLocalsError. Otherwise, the original error is reraised, preserving the backtrace for easier debugging.

  • Chore: Documentation Tweak 📚
    A small but mighty change: "encryption,database" is now "encryption, database". Just a tiny tweak to make things clearer!

These updates are designed to make your Rails journey more efficient and enjoyable. Keep coding and have fun! 🌟

Included Commits

2025-01-04T10:21:53 See commit

This commit addresses an issue in the ActiveRecord library of Rails where StringJoin nodes were being eagerly compiled, which was unnecessary and could lead to the loss of bind variables, ultimately resulting in broken queries. The changes made to the join_association.rb file streamline the process by modifying how joins are constructed and how constraints are appended. The code now avoids eager compilation of these nodes, thus preserving the integrity of bind variables and ensuring that queries function correctly.

Additionally, the commit includes updates to tests in join_model_test.rb and model definitions in post.rb to verify that the changes do not introduce any errors, particularly with eager loading and associations involving StringJoins. The tests confirm that the modified join logic works as intended, maintaining the expected behavior of the ActiveRecord associations. Overall, this commit enhances the robustness and reliability of query construction in ActiveRecord.

Files changed

  • activerecord/lib/active_record/associations/join_dependency/join_association.rb
  • activerecord/test/cases/associations/join_model_test.rb
  • activerecord/test/models/post.rb
2025-01-05T22:19:37 See commit

This commit introduces significant updates to the assert_notification method within the ActiveSupport testing framework, enhancing its functionality for testing notification emissions. The key change is that assert_notification now defaults to matching on a subset of the payload, allowing for more flexible assertions when verifying notifications. This means that tests can now pass even if the emitted notification contains additional keys beyond those specified in the assertion. Additionally, the method has been modified to return the matched notification, enabling developers to perform further assertions on the notification's payload if needed.

The commit also includes a migration of existing tests to utilize the new assert_notification behavior, ensuring that they conform to the updated method's functionality. This migration involved updating various test files across the ActionMailer, ActionController, ActiveJob, ActiveRecord, and ActiveStorage components, where the previous approach of capturing notifications has been replaced with the new assertion method. Alongside these changes, the commit includes cleanups to improve code clarity and maintainability, particularly in the ImageAnalyzer::VipsTest class. Overall, these enhancements aim to streamline notification testing and improve the developer experience when working with Rails' notification system.

Files changed

  • actionmailer/test/base_test.rb
  • actionpack/test/controller/allow_browser_test.rb
  • actionpack/test/controller/caching_test.rb
  • actionpack/test/controller/redirect_test.rb
  • actionpack/test/dispatch/routing/instrumentation_test.rb
  • actionview/test/activerecord/partial_rendering_query_test.rb
  • activejob/test/cases/queuing_test.rb
  • activerecord/test/activejob/job_runtime_test.rb
  • activerecord/test/cases/associations/eager_test.rb
  • activerecord/test/cases/instrumentation_test.rb
  • activestorage/test/analyzer/image_analyzer/vips_test.rb
  • activesupport/CHANGELOG.md
  • activesupport/lib/active_support/testing/notification_assertions.rb
  • activesupport/test/testing/notification_assertions_test.rb
  • railties/test/application/initializers/notifications_test.rb
2025-01-06T19:32:31 See commit

This commit addresses an issue with how ArgumentError exceptions were handled during template rendering in Rails. Previously, when an ArgumentError occurred, it was often obscured by the strict local error handling, leading to confusion as developers received an unrelated backtrace that made debugging difficult. The change introduces a new exception, ActionView::StrictLocalsError, specifically for errors related to strict locals, while ensuring that all other ArgumentError instances are reraised with their original backtraces intact.

As a result, developers can now more easily identify and resolve issues in their templates, as the source of the error remains clear. Importantly, ActionView::StrictLocalsError is a subclass of ArgumentError, which means that existing code that rescues ArgumentError will continue to function without any modifications. This enhancement improves the overall debugging experience in Rails template rendering.

Files changed

2025-01-07T02:43:46 See commit

This commit involves a minor modification to the Ruby on Rails documentation, specifically in the contributing guide. The change corrects the formatting of the phrase "encryption,database" to "encryption, database" by adding a space between the two terms, enhancing readability and clarity.

The update is reflected in the bug report template link for Active Record issues, ensuring that contributors have clear and properly formatted references when reporting bugs related to models and encryption in the database. The commit also includes a note to skip continuous integration checks, indicating that the changes are primarily cosmetic and do not affect the functionality of the documentation.

Files changed

  • guides/source/contributing_to_ruby_on_rails.md
2025-01-07T18:52:03 See commit

This commit introduces a modification to the way Active Storage is handled during service validation, specifically for tasks like assets:precompile that do not require Active Storage functionality. By preventing the loading of ActiveStorage::Blob in these scenarios, the commit aims to streamline the process and avoid potential issues that could arise from misconfigurations of Active Storage when it is not needed.

The changes made in this commit enhance performance and reduce unnecessary dependencies during specific tasks, ensuring that only the relevant components are loaded. This improvement helps maintain the integrity of the task execution by eliminating the risk of encountering errors related to Active Storage when it is not applicable.

Files changed

2025-01-08T11:29:41 See commit

This commit addresses a deprecation issue related to ActiveSupport::Multibyte in the ActiveRecord quoting mechanism. By removing the direct dependency on ActiveSupport::Multibyte::Chars, the changes prevent the triggering of deprecation warnings when quoting values of this type. The code modifications include adjustments to the quote and type_cast methods, allowing them to handle ActiveSupport::Multibyte::Chars gracefully without raising errors, while still maintaining compatibility with other data types.

The update involves a total of 19 changes, including 14 additions and 5 deletions, primarily focusing on refining how the system quotes and type casts various value types. This ensures that ActiveSupport::Multibyte::Chars can be processed correctly without causing issues in the quoting logic, ultimately leading to a smoother experience for developers using ActiveRecord in their applications.

Files changed

  • activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
2025-01-08T16:04:41 See commit

This commit enhances error reporting for invalid :only or :except options used in the #resource or #resources methods by including the resource name in the raised ArgumentError. This improvement aids developers in quickly identifying the source of the issue, particularly in cases where routes are defined by gems, thus streamlining the debugging process.

Previously, the error message did not specify which resource was causing the issue, making it challenging to trace the problem. With the new implementation, the error message now includes the relevant resource name, providing clearer context. For example, an error for the resources :products route will explicitly mention it, making it easier for developers to resolve the issue. This change addresses issue number 54134 on the Rails GitHub repository.

Files changed