Skip to content

Commit

Permalink
validation is case insensitive, trims white space
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Jul 30, 2023
1 parent fceede7 commit bea3dc9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/learning_hour_type.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
class LearningHourType < ApplicationRecord
belongs_to :casa_org

validates :name, presence: true, uniqueness: {scope: %i[casa_org]}
validates :name, presence: true, uniqueness: {scope: %i[casa_org], case_sensitive: false}
before_validation :strip_name
default_scope { order(position: :asc, name: :asc) }
scope :for_organization, ->(org) { where(casa_org: org).order(:name) }
scope :active, -> { where(active: true) }

private

def strip_name
self.name = name.strip if name
end
end

# == Schema Information
Expand Down

0 comments on commit bea3dc9

Please sign in to comment.