This blog is part of our Rails 6.1 series.
Rails 6.1 simplifies retrieving values of attributes on the Active Record model instance
by adding the
values_at attribute method. This is similar to the
values_at method in
Let’s check out an example of extracting values from a
User model instance.
Before Rails 6.1
As shown below using
full_name, which is a method, returns
After changes in Rails 6.1
Rails 6.1 added the
values_at method on Active Record which returns an array containing the values associated with the given methods.
Check out the pull request for more details.