Updated find_by methods
This commit is contained in:
@@ -4,9 +4,9 @@ class Badge < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.get (input)
|
def self.get (input)
|
||||||
if input.is_a?(String) || input.is_a?(Symbol)
|
if input.is_a?(String) || input.is_a?(Symbol)
|
||||||
Badge.find_by_name(input)
|
Badge.find_by(name: input)
|
||||||
elsif input.is_a?(Fixnum)
|
elsif input.is_a?(Fixnum)
|
||||||
Badge.find_by_id(input)
|
Badge.find_by(id: input)
|
||||||
elsif input.is_a?(Badge)
|
elsif input.is_a?(Badge)
|
||||||
return input
|
return input
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ class Comment < ActiveRecord::Base
|
|||||||
background_mailer(mails)
|
background_mailer(mails)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ class Info < ActiveRecord::Base
|
|||||||
[id, to_s.parameterize].join("-")
|
[id, to_s.parameterize].join("-")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ class Label < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
class RegisterToken < ActiveRecord::Base
|
class RegisterToken < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ class Role < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is? (name)
|
def is? (name)
|
||||||
!!(Role.find_by_name(name) == self)
|
!!(Role.find_by(name: name) == self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get (input)
|
def self.get (input)
|
||||||
if input.is_a?(String) || input.is_a?(Symbol)
|
if input.is_a?(String) || input.is_a?(Symbol)
|
||||||
Role.find_by_name(input)
|
Role.find_by(name: input)
|
||||||
elsif input.is_a?(Fixnum)
|
elsif input.is_a?(Fixnum)
|
||||||
Role.find_by_id(input)
|
Role.find_by(id: input)
|
||||||
elsif input.is_a?(Role)
|
elsif input.is_a?(Role)
|
||||||
return input
|
return input
|
||||||
end
|
end
|
||||||
@@ -31,7 +31,7 @@ class Role < ActiveRecord::Base
|
|||||||
if role.is_a?(Role)
|
if role.is_a?(Role)
|
||||||
self.value - role.value
|
self.value - role.value
|
||||||
elsif role.is_a?(Symbol)
|
elsif role.is_a?(Symbol)
|
||||||
self <=> Role.find_by_name(role)
|
self <=> Role.find_by(name: role)
|
||||||
else
|
else
|
||||||
self.to_i <=> role
|
self.to_i <=> role
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -64,4 +64,4 @@ class Threadreply < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
background_mailer(mails)
|
background_mailer(mails)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user