Explorar o código

Ensure check always has a state

Andrew Kane %!s(int64=8) %!d(string=hai) anos
pai
achega
33a79a1002
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      app/models/blazer/check.rb

+ 6 - 0
app/models/blazer/check.rb

@@ -4,6 +4,12 @@ module Blazer
 
     validates :query_id, presence: true
 
+    before_validation :set_state
+
+    def set_state
+      self.state ||= "new"
+    end
+
     def split_emails
       emails.to_s.downcase.split(",").map(&:strip)
     end