Sha256: 5288d1c1ff26316e30a65dcffd54c2841de36d90c0867e399fc79694092c20a3

Contents?: true

Size: 368 Bytes

Versions: 10

Compression:

Stored size: 368 Bytes

Contents

module Qcourses

  class Location < Sequel::Model
    plugin :validation_helpers
    one_to_many :events

    def validate
      validates_presence :name
    end

    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
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
qcourses-0.1.11 lib/qcourses/models/location.rb
qcourses-0.1.10 lib/qcourses/models/location.rb
qcourses-0.1.9 lib/qcourses/models/location.rb
qcourses-0.1.8 lib/qcourses/models/location.rb
qcourses-0.1.7 lib/qcourses/models/location.rb
qcourses-0.1.6 lib/qcourses/models/location.rb
qcourses-0.1.5 lib/qcourses/models/location.rb
qcourses-0.1.4 lib/qcourses/models/location.rb
qcourses-0.1.3 lib/qcourses/models/location.rb
qcourses-0.1.2 lib/qcourses/models/location.rb