Permalink
Browse files

Normalize question values

  • Loading branch information...
1 parent 2ac4517 commit ab6545715b969bd9d09025ee42547edb17a66e29 @rwdaigle committed May 23, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 app/models/unit.rb
View
@@ -4,6 +4,8 @@ class Unit < ActiveRecord::Base
validates_presence_of :question, :subject
validates_uniqueness_of :question, :scope => :subject_id
+
+ before_save :normalize_question
belongs_to :subject
has_many :learnings, :dependent => :delete_all
@@ -64,4 +66,8 @@ def process!(overwrite = false)
def to_log
{ unit_id: self.id, unit: question }
end
+
+ def normalize_question
+ self.question = question.strip.downcase if question
+ end
end

0 comments on commit ab65457

Please sign in to comment.