diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-12-14 22:42:07 +0800 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-12-19 11:24:54 +0100 |
commit | cc5099c5ce79a7c062e2197b47f5f8a81bb48292 (patch) | |
tree | 379058dc0f48c627767e02c8787e42dd19808880 /app | |
parent | 1ae28e0e7b5996536e4c8005c362d3f82088c77c (diff) | |
download | gitlab-ce-cc5099c5ce79a7c062e2197b47f5f8a81bb48292.tar.gz |
Move schema aware defaults to build_from_defaults
This way we can reuse the safe setting
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/cacheable_attributes.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/concerns/cacheable_attributes.rb b/app/models/concerns/cacheable_attributes.rb index 75592bb63e2..3d60f6924c1 100644 --- a/app/models/concerns/cacheable_attributes.rb +++ b/app/models/concerns/cacheable_attributes.rb @@ -23,7 +23,12 @@ module CacheableAttributes end def build_from_defaults(attributes = {}) - new(defaults.merge(attributes)) + final_attributes = defaults + .merge(attributes) + .stringify_keys + .slice(*column_names) + + new(final_attributes) end def cached |