Allow ActiveRecord::Core#slice to take array of attrs (like ActiveRecord::QueryMethods#select)

Imagine you have some code as follows:

class User < ApplicationRecord
PUBLIC_FIELDS = %i(foo bar baz).freeze

scope :public_fooed, -> { select(PUBLIC_FIELDS).where(foo: true) }

def publicize


It slightly annoys me that to filter attributes at the model class level (while doing a ::select), you don’t need to splat PUBLIC_FIELDS, but you do when doing it at the model object level (with #slice).

We could safely flatten the arguments to #slice to remove the need to splat since ActiveRecord::Core#slice will never have attributes (or methods) that are arrays. This would bring it in line with ::select