rails changelog


Here's a fun and exciting update on the latest changes to our project! 🎉 We've been working hard to improve the robustness, flexibility, and overall awesomeness of our codebase. Check out the cool new features and fixes we've rolled out:

  • New Feature: Local CI Magic with bin/ci 🚀
    Say hello to our brand-new local Continuous Integration tool, bin/ci, designed to streamline your development workflow. This nifty tool runs all your tests, linters, and security scanners, giving you a green light when everything's good to go. Plus, you can customize your CI workflow with a super cool Domain-Specific Language (DSL). Co-authored by the legendary David Heinemeier Hansson, this feature is sure to make your coding life easier and more fun!

  • Improvement: Smarter ActiveRecord Migrations 🧙‍♂️
    We've implemented respond_to_missing? for ActiveRecord::Migration, making your migration scripts more robust and flexible. This enhancement ensures your migration class can handle dynamic method calls like a pro, reducing confusion and improving the overall developer experience.

  • Improvement: Session Controller Tests for Auth Generator 🔒
    We've added automated tests for the session controller in the authentication generator, boosting your app's reliability and security. These tests ensure session management is spot-on, so you can focus on building amazing features without worrying about pesky session bugs.

  • Improvement: PostgreSQL Adapter Connection Handling 🛠️
    Our PostgreSQLAdapter now gracefully handles connection failures when the server version is reported as 0. This enhancement ensures your app can recover from connection hiccups and keeps your database interactions smooth and reliable.

  • Bugfix: Disconnect on configure_connection Failures 🐛
    We've squashed a bug that could leave your Adapter in a half-initialized state if configure_connection failed. Now, we'll disconnect and retry from scratch, ensuring your connections are always in tip-top shape.

  • Bugfix: Timeout Handling in Connection Configuration ⏱️
    We've improved the handling of Timeout.timeout errors in AbstractAdapter#attempt_configure_connection. By rescuing Exception, we're making sure timeout-related issues don't throw a wrench in your app's stability.

  • Bugfix: Mailer Generation Only If Needed 📬
    No more unnecessary mailer files cluttering your app! We've updated the auth generator to create mailer files only if ActionMailer is in use. This change prevents potential breakage and keeps your app clean and efficient.

We hope you enjoy these updates as much as we enjoyed creating them! Keep coding and stay awesome! 🌟

Included Commits

2025-03-07T09:24:27 See commit

This commit addresses a bug related to the configure_connection method in Rails, which could leave the Adapter in a partially initialized state if an error occurs during one of its queries. Prior to Rails 7.0, such failures were relatively rare, as the Adapter instance was only added to the connection pool after a successful connection. However, with the introduction of lazy connection initialization in Rails 7.1, the Adapter is now added to the pool before the connection attempt, increasing the likelihood of encountering this issue.

To resolve this, the commit implements a mechanism to disconnect the Adapter if an error is raised during the configure_connection process. This ensures that if a retry is necessary, the system will attempt to reconnect and reconfigure the connection from scratch, thereby preventing the Adapter from remaining in an inconsistent state.

Files changed

2025-03-07T13:22:03 See commit

This commit enhances the PostgreSQLAdapter in ActiveRecord by adding error handling for cases where the PostgreSQL server version is reported as 0, which indicates a connection failure. The get_database_version method was modified to raise an ActiveRecord::ConnectionFailed exception with a clear error message when the server version is 0. This change aims to improve the robustness of the connection handling by ensuring that the application can gracefully respond to situations where it cannot determine the database version.

Additionally, the commit includes a new test case that verifies the behavior of the adapter when it encounters a bad connection due to the server version being reported as 0. The test ensures that the appropriate exception is raised and that the connection can be retried successfully afterward. This implementation enhances the reliability of database connections in ActiveRecord by addressing potential failure scenarios more effectively.

Files changed

  • activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  • activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
2025-03-07T17:11:54 See commit

This commit introduces automated tests for the session controller as part of the authentication generator in the Rails framework. Specifically, it adds a new test file, sessions_controller_test.rb, which includes various tests to validate the functionality of the session management, such as creating a session with valid and invalid credentials, as well as destroying a session. The tests ensure that the appropriate responses are returned and that session cookies are managed correctly during these operations.

Additionally, the commit updates the generator to include the new test file when the authentication generator is invoked, enhancing the testing capabilities for developers implementing authentication features. The changes are documented in the changelog, highlighting the collaborative effort by co-author David Heinemeier Hansson. Overall, this update aims to improve the reliability and security of session handling in Rails applications.

Files changed

  • railties/CHANGELOG.md
  • railties/lib/rails/generators/test_unit/authentication/authentication_generator.rb
  • railties/lib/rails/generators/test_unit/authentication/templates/test/controllers/sessions_controller_test.rb
  • railties/test/generators/authentication_generator_test.rb
2025-03-08T09:37:23 See commit

This commit introduces a new local Continuous Integration (CI) tool called bin/ci for Ruby on Rails applications, enhancing the development workflow by allowing developers to run all tests, linters, and security scanners before merging pull requests. The tool provides a simple command-line interface to execute defined steps, track their success or failure, and optionally sign off on work with a green status for pull requests. The implementation includes a Domain-Specific Language (DSL) for defining CI workflows, making it easy for developers to customize their CI processes.

In addition to the core functionality, the commit includes various improvements such as enhanced DSL capabilities, better performance, and comprehensive documentation. It also sets up default configurations for new Rails applications, allowing for immediate use of the CI tool. The commit is co-authored by David Heinemeier Hansson and includes tests to ensure the reliability of the new CI features. Overall, this enhancement aims to streamline the development process and improve code quality through automated checks.

Files changed

  • .rubocop.yml
  • activesupport/lib/active_support.rb
  • activesupport/lib/active_support/continuous_integration.rb
  • activesupport/test/continuous_integration_test.rb
  • railties/CHANGELOG.md
  • railties/lib/rails/generators/rails/app/app_generator.rb
  • railties/lib/rails/generators/rails/app/templates/bin/ci.tt
  • railties/lib/rails/generators/rails/app/templates/config/ci.rb.tt
  • railties/test/application/bin_ci_test.rb
  • railties/test/generators/app_generator_test.rb
  • railties/test/generators/plugin_generator_test.rb
2025-03-09T02:04:14 See commit

The commit introduces the implementation of the respond_to_missing? method for the ActiveRecord::Migration class. This enhancement allows for better handling of method calls that are not explicitly defined within the migration class, improving the robustness and flexibility of migration scripts. By defining this method, the migration class can now more effectively respond to dynamic method calls, ensuring that it behaves correctly when methods are invoked that may not be present in the class itself.

Additionally, this change likely improves the overall user experience for developers working with ActiveRecord migrations by providing clearer error messages and reducing potential confusion when interacting with the migration API. Overall, this commit enhances the functionality and reliability of ActiveRecord migrations, making them more adaptable to various use cases.

Files changed

2025-03-11T18:21:15 See commit

This commit modifies the authentication generator to only create mailer files if ActionMailer is being utilized in the application. The rationale behind this change is that generating unnecessary mailer-related code can lead to complications, particularly when the generated PasswordMailer attempts to inherit from a nonexistent ApplicationMailer, resulting in application errors that may not surface until runtime or deployment.

By implementing this adjustment, the commit addresses issue #54501, streamlining the generator's output and preventing potential breakage in applications that do not require mailer functionality. The changes enhance the overall robustness of the generator, ensuring that developers only receive relevant code that aligns with their application's requirements.

Files changed

2025-03-12T10:59:48 See commit

The commit modifies the AbstractAdapter#attempt_configure_connection method to properly handle exceptions raised by the configure_connection process, specifically when a Timeout.timeout occurs. Previously, the method may not have adequately addressed the Timeout::ExitError, which is a subclass of Exception. By rescuing Exception, the code ensures that this type of error is effectively managed, preventing it from causing unhandled exceptions in the application.

Overall, this change enhances the robustness of the connection configuration process by ensuring that timeout-related errors are captured and handled appropriately, thereby improving the stability of the application.

Files changed