diff options
author | Markus Koller <markus-koller@gmx.ch> | 2017-09-28 16:49:42 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-28 16:49:42 +0000 |
commit | e9eae3eb0dd25e4a34c9a4b6bcc7de312dde4489 (patch) | |
tree | d2402a99dd96927ae458f49cbd7de8ad043e297a /app/models | |
parent | 93a33556e3e01a83c1af9c21e11ff433b624c40d (diff) | |
download | gitlab-ce-e9eae3eb0dd25e4a34c9a4b6bcc7de312dde4489.tar.gz |
Support custom attributes on users
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/models/user_custom_attribute.rb | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 103ac78783f..4d523aa983f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,6 +130,8 @@ class User < ActiveRecord::Base has_many :assigned_issues, class_name: "Issue", through: :issue_assignees, source: :issue has_many :assigned_merge_requests, dependent: :nullify, foreign_key: :assignee_id, class_name: "MergeRequest" # rubocop:disable Cop/ActiveRecordDependent + has_many :custom_attributes, class_name: 'UserCustomAttribute' + # # Validations # diff --git a/app/models/user_custom_attribute.rb b/app/models/user_custom_attribute.rb new file mode 100644 index 00000000000..eff25b31f9b --- /dev/null +++ b/app/models/user_custom_attribute.rb @@ -0,0 +1,6 @@ +class UserCustomAttribute < ActiveRecord::Base + belongs_to :user + + validates :user_id, :key, :value, presence: true + validates :key, uniqueness: { scope: [:user_id] } +end |