about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-15 13:47:08 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-15 14:12:24 -0500
commit436f7984d9ea60ec0dc222fcbcaa795792942781 (patch)
treed21f26779ed8fe1a7efee820cce07338db9f317a /app/models
parent9a2f0131c6cddef3ef0e7faa73070945f0d4f452 (diff)
move user variables to `users` relation
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb5
-rw-r--r--app/models/user.rb5
2 files changed, 10 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 8187bc7d9..d30c2a9ec 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -313,6 +313,10 @@ class Account < ApplicationRecord
     self[:also_known_as] || []
   end
 
+  def field
+    @field ||= fields.map { |f| [f.name, f.value] }.to_h
+  end
+
   def fields
     (self[:fields] || []).map { |f| Field.new(self, f) }
   end
@@ -352,6 +356,7 @@ class Account < ApplicationRecord
     self.fields = tmp
   end
 
+  # needs to be removed after migration
   def vars
     self[:vars]
   end
diff --git a/app/models/user.rb b/app/models/user.rb
index 5f1ffb595..6aafa124a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -38,6 +38,7 @@
 #  chosen_languages          :string           is an Array
 #  created_by_application_id :bigint(8)
 #  approved                  :boolean          default(TRUE), not null
+#  vars                      :jsonb            not null
 #
 
 class User < ApplicationRecord
@@ -151,6 +152,10 @@ class User < ApplicationRecord
   attr_reader :invite_code
   attr_writer :external
 
+  def vars
+    self[:vars]
+  end
+
   def confirmed?
     confirmed_at.present?
   end