]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user_role.rb
Ensure that issue comments have associated issues and users.
[rails.git] / app / models / user_role.rb
index efa540fec851de209b0a7d9d4fa74b63a60ab10d..967850145f838b4dcff1af82858235dbcecebec7 100644 (file)
@@ -1,8 +1,8 @@
 class UserRole < ActiveRecord::Base
-
-  ALL_ROLES = ['administrator', 'moderator']
-
-  validates_inclusion_of :role, :in => ALL_ROLES
   belongs_to :user
+  belongs_to :granter, :class_name => "User"
+
+  ALL_ROLES = %w[administrator moderator].freeze
 
+  validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }
 end