Rails 7.1 ActiveRecord adds normalizes API for attribute values

Sometimes you may want to standardize the data before saving it to the database. For example, downcasing emails, removing any leading and trailing whitespaces, and so on. Rails 7.1 adds ActiveRecord::Base::normalizes API, which allows you to normalize attribute values to a common format before saving them to the database. This can help improve the integrity and consistency of your data and make it simpler to query records based on attribute values. Before Rails 7.1 Normalizing it in before_validation or before_save callback class User < ActiveRecord::Base before_validation do self.name = name.downcase.titleize

Improvements to in_order_of active record query method in Rails 7.1

Rails 7 has introduced the in_order_of method which allows to sort records in a specific order. There is a detailed explanation of it in the article Rails 7 adds in_order_of for ActiveRecord::QueryMethods and Enumerable. This is a follow-up article to that one, in which we will explore how the in_order_of method has been improved in Rails 7.1. Rails 7 adds in_order_of for ActiveRecord::QueryMethods and EnumerableRails 7 has added in_order_of method for ActiveRecord::QueryMethods and Enumerable to retrieve the data in an explicit order.Kiprosh BlogsSupriya Laxman MedankarAllows