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
slice(*PUBLIC_FIELDS)
end
end
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`
Thoughts?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.