~mrls/activerecord-except

ref: 7a5541a4540035581a0a30f50d62d22987de03af activerecord-except/lib/activerecord/except/relation.rb -rw-r--r-- 251 bytes
7a5541a4Mauro Morales Initial commit 1 year, 22 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
# frozen_string_literal: true

module ActiveRecord
  class Relation
    def except(*fields)
      inverted_fields = klass._default_attributes.keys.map(&:to_sym).reject { |attr| fields.include?(attr) }
      _select!(inverted_fields)
    end
  end
end