Added badge system

This commit is contained in:
MrYummy
2017-05-28 17:39:06 -04:00
parent 992406a20b
commit 1b4a270038
11 changed files with 124 additions and 29 deletions

18
app/models/badge.rb Normal file
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

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