mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
Change user.rb to fix migration
Gracefully fix nil team value
This commit is contained in:
parent
0a6879230f
commit
a081db3ba0
2 changed files with 9 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
# Add changes only specific to dev. env.
|
# Add changes only specific to dev. env.
|
||||||
|
|
||||||
# Scrypt max time to reduce migration time
|
# Scrypt max time to reduce migration time
|
||||||
SCRYPT_MAX_TIME=0.001
|
SCRYPT_MAX_TIME=0.0005
|
||||||
|
|
||||||
MYSQL_DATABASE=ensl_development
|
MYSQL_DATABASE=ensl_development
|
||||||
|
|
||||||
|
|
|
@ -335,6 +335,11 @@ class User < ActiveRecord::Base
|
||||||
issues.unread_by(self)
|
issues.unread_by(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def duplicates
|
||||||
|
# TODO: user arel
|
||||||
|
User.where('lower(username) = ? AND users.id != ?', username.downcase, id)
|
||||||
|
end
|
||||||
|
|
||||||
def correct_steamid_universe
|
def correct_steamid_universe
|
||||||
if steamid.present?
|
if steamid.present?
|
||||||
steamid[0] = "0"
|
steamid[0] = "0"
|
||||||
|
@ -344,8 +349,9 @@ class User < ActiveRecord::Base
|
||||||
# FIXME: if team has been removed
|
# FIXME: if team has been removed
|
||||||
def validate_team
|
def validate_team
|
||||||
if team and !active_teams.exists?({:id => team.id})
|
if team and !active_teams.exists?({:id => team.id})
|
||||||
|
# Attempts to fix team, gracefully
|
||||||
self.team = nil
|
self.team = nil
|
||||||
self.save!
|
self.save
|
||||||
errors.add :team
|
errors.add :team
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue