Class: Qcourses::Location

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/qcourses/models/location.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_create_bij_insensitive_name(new_location) ⇒ Object



11
12
13
14
# File 'lib/qcourses/models/location.rb', line 11

def self.find_or_create_bij_insensitive_name(new_location)
  return nil if new_location.empty?
  filter(:name.ilike("#{new_location}%") ).first || create(name: new_location)
end

Instance Method Details

#validateObject



7
8
9
# File 'lib/qcourses/models/location.rb', line 7

def validate
  validates_presence :name
end