mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Fix team validation
This commit is contained in:
parent
8c21aef762
commit
d3ef9db9e9
1 changed files with 5 additions and 2 deletions
|
@ -48,7 +48,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
attribute :lastvisit, :datetime, default: Time.now.utc
|
attribute :lastvisit, :datetime, default: Time.now.utc
|
||||||
|
|
||||||
belongs_to :team
|
belongs_to :team, :optional => true
|
||||||
has_one :profile, :dependent => :destroy
|
has_one :profile, :dependent => :destroy
|
||||||
has_many :bans, :dependent => :destroy
|
has_many :bans, :dependent => :destroy
|
||||||
has_many :articles, :dependent => :destroy
|
has_many :articles, :dependent => :destroy
|
||||||
|
@ -132,7 +132,6 @@ class User < ActiveRecord::Base
|
||||||
validate :validate_team
|
validate :validate_team
|
||||||
|
|
||||||
before_create :init_variables
|
before_create :init_variables
|
||||||
|
|
||||||
before_save :correct_steamid_universe
|
before_save :correct_steamid_universe
|
||||||
|
|
||||||
accepts_nested_attributes_for :profile
|
accepts_nested_attributes_for :profile
|
||||||
|
@ -292,8 +291,12 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 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})
|
||||||
|
byebug
|
||||||
|
self.team = nil
|
||||||
|
self.save!
|
||||||
errors.add :team
|
errors.add :team
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue