summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-11 10:21:22 +0200
committerRémy Coutable <remy@rymai.me>2016-10-11 10:21:26 +0200
commit8d8282b42e765d20532d32b0598f42ea707f31f0 (patch)
treea5792351510fa02681d923d061cc72c7bef7efb5
parentebba49149395ba6fb0f14c3aa9c46a496b234dea (diff)
downloadgitlab-ce-8d8282b42e765d20532d32b0598f42ea707f31f0.tar.gz
Add a safeguard in User#set_projects_limitnew-gitlab-users-clear_all_authentication_tokens-task
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--app/models/user.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 892ac28d5b3..f367f4616fb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -589,6 +589,11 @@ class User < ActiveRecord::Base
end
def set_projects_limit
+ # `User.select(:id)` raises
+ # `ActiveModel::MissingAttributeError: missing attribute: projects_limit`
+ # without this safeguard!
+ return unless self.has_attribute?(:projects_limit)
+
connection_default_value_defined = new_record? && !projects_limit_changed?
return unless self.projects_limit.nil? || connection_default_value_defined