Skip to content

Instantly share code, notes, and snippets.

@inopinatus
Created October 14, 2020 00:53
Show Gist options
  • Save inopinatus/1517ceccfe25f03764fe7cf5a7e08897 to your computer and use it in GitHub Desktop.
Save inopinatus/1517ceccfe25f03764fe7cf5a7e08897 to your computer and use it in GitHub Desktop.
values_at for active record models
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
@inopinatus
Copy link
Author

Until rails/rails#36481 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment