[83970] branches/gsoc11-statistics/stats-server/app/models/user.rb

derek at macports.org derek at macports.org
Tue Sep 13 18:25:50 PDT 2011


Revision: 83970
          http://trac.macports.org/changeset/83970
Author:   derek at macports.org
Date:     2011-09-13 18:25:50 -0700 (Tue, 13 Sep 2011)
Log Message:
-----------
Added UUID validations. uuid must be present, and it must be valid (verified by the UUID gem)

Modified Paths:
--------------
    branches/gsoc11-statistics/stats-server/app/models/user.rb

Modified: branches/gsoc11-statistics/stats-server/app/models/user.rb
===================================================================
--- branches/gsoc11-statistics/stats-server/app/models/user.rb	2011-09-14 01:15:43 UTC (rev 83969)
+++ branches/gsoc11-statistics/stats-server/app/models/user.rb	2011-09-14 01:25:50 UTC (rev 83970)
@@ -1,4 +1,13 @@
 class User < ActiveRecord::Base
   has_one  :os_statistic
   has_many :installed_ports
+  
+  validates_presence_of :uuid
+  validate :uuid_cannot_be_invalid
+  
+  def uuid_cannot_be_invalid
+    if !UUID.validate(uuid)
+      errors.add(:uuid, "uuid must be a valid universally unique identifier")
+    end
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110913/55256720/attachment-0001.html>


More information about the macports-changes mailing list