From 436f7984d9ea60ec0dc222fcbcaa795792942781 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Mon, 15 Jul 2019 13:47:08 -0500 Subject: move user variables to `users` relation --- app/models/account.rb | 5 +++++ app/models/user.rb | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'app/models') 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 -- cgit