Added badge system

This commit is contained in:
MrYummy
2017-05-29 00:10:41 +02:00
parent 992406a20b
commit 276949c0cd
11 changed files with 124 additions and 29 deletions
+18
View File
@@ -0,0 +1,18 @@
class Badge < ActiveRecord::Base
include Comparable
has_many :users
def self.get (input)
if input.is_a?(String) || input.is_a?(Symbol)
Badge.find_by_name(input)
elsif input.is_a?(Fixnum)
Badge.find_by_id(input)
elsif input.is_a?(Badge)
return input
end
end
def to_s
self.name
end
end
+2 -1
View File
@@ -5,6 +5,7 @@ class User < ActiveRecord::Base
strip_attributes
belongs_to :role
belongs_to :badge
has_secure_password
@@ -173,4 +174,4 @@ class User < ActiveRecord::Base
def set_email_token
self.email_token ||= SecureRandom.hex(16)
end
end
end