Module: Shared::IsData::Scopes::ClassMethods

Defined in:
app/models/concerns/shared/is_data/scopes.rb

Instance Method Summary (collapse)

Instance Method Details

- (Scope) not_ids(*ids)

! Not built for collisions

Returns:

  • (Scope)


21
22
23
# File 'app/models/concerns/shared/is_data/scopes.rb', line 21

def not_ids(*ids)
  where.not(id: ids)
end

- (Scope) not_self(object)

a where clause that excludes the present object from being selected

Returns:

  • (Scope)


8
9
10
11
12
13
14
# File 'app/models/concerns/shared/is_data/scopes.rb', line 8

def not_self(object)
  if object.nil? || object.id.blank?
    where(object.class.table_name => {id: '<> 0'})
  else
    where(object.class.arel_table[:id].not_eq(object.to_param))
  end
end