Added badge system
This commit is contained in:
18
app/models/badge.rb
Normal file
18
app/models/badge.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user