Created
October 14, 2020 00:53
-
-
Save inopinatus/1517ceccfe25f03764fe7cf5a7e08897 to your computer and use it in GitHub Desktop.
values_at for active record models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
unless instance_methods.include?(:values_at) | |
def values_at(*methods) | |
methods.flatten.map! { |method| public_send(method) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Until rails/rails#36481 merged.