Hi, it’s Greg, bringing you the latest news about Ruby on Rails.
We have exciting news from the Rails Foundation! The first-ever Rails World Conference is coming! Join the community on October 5 & 6 in Amsterdam, Netherlands, for keynotes, technical sessions, and all things Rails. A website with tickets and a CFP is coming soon! You can read the announcement here.
Reset composite primary key in #dup
This pull request ensures that the composite primary key is reset when #dup
is called on an instance of an ActiveRecord::Base
subclass.
For example:
class TravelRoute < ActiveRecord::Base
self.primary_key = [:origin, :destination]
end
route = TravelRoute.new(origin: "NYC", destination: "LAX")
route.dup # => #<TravelRoute origin: nil, destination: nil>
Ensure pre-7.1 migrations use legacy index names when using create_table
A follow-up to 47753 ensures the older versions of Active Record will use the legacy index names rather than the new truncated ones.
Correctly dump check constraints for MySQL 8.0.16+
If you’re using MySQL 8.0.16+ and your database contains a table with a check constraint, the first and last characters of the constraint will be stripped when dumping the schema. This makes it impossible to use check constraints in a MySQL 8.0 database with the :ruby schema format, because once they are dumped, they cannot be re-imported.
The change in this pull request fixed the issue.
Only default to select primary key when non-composite
Historically, when a relation is handled in the predicate builder has no selected values, it falls back to selecting the model’s primary key. This tends to work well in single-column primary key cases. In composite key cases, this can lead to attempting to compare a single attribute to a list of attributes, which builds malformed SQL.
The check this pull request added prevents any code from attempting to do so, by raising in composite primary key cases when defaulting to primary key. For now, users can build these queries themselves.
Add *_deliver callbacks for Action Mailer
This pull request adds deliver callbacks (e.g. before_deliver
, after_deliver
, around_deliver
) to Action Mailer. The benefit is that it allows delivery observer/interceptor-like behaviors within the context of the instance of ActionMailer::Base
rather than operating only on the Mail object.
Active Job verbose logging
A verbose_enqueue_logs
configuration option is added to Active Job to display the caller of background job enqueue in the log to help with debugging.
It is enabled in development only for new and upgraded applications. Not recommended for use in the production environment since it relies on Ruby’s Kernel#caller
which is fairly slow.
There were a lot of documentation-related changes I didn’t cover, you can view the whole list of changes here.
We had 21 contributors to the Rails codebase this past week!
Until next time!
Subscribe to get these updates mailed to you.