From 09fc23fd56c25826890f6e0d12e1329ad2c4fb83 Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Tue, 15 Dec 2020 05:16:27 +0700 Subject: [PATCH] Move back from after_initialize to explicit call (#11881) --- app/models/profile.rb | 6 ++++-- config/application.rb | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index bd7d752ae..0a5b1edc5 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -25,8 +25,6 @@ class Profile < ApplicationRecord }.with_indifferent_access.freeze # Generates typed accessors for all currently defined profile fields. - # This is also used in config/application.rb to initialize profiles on app - # boot in the after_initialize hook. def self.refresh_attributes! return if ENV["ENV_AVAILABLE"] == "false" return unless Database.table_exists?("profiles") @@ -36,6 +34,10 @@ class Profile < ApplicationRecord end end + # Set up all profile attributes when this class loads so all store_attribute + # accessors get defined immediately. + refresh_attributes! + # Returns an array of all currently defined `store_attribute`s on `data`. def self.attributes (stored_attributes[:data] || []).map(&:to_s) diff --git a/config/application.rb b/config/application.rb index d1fbae8fe..f48c1c6fc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,9 +81,6 @@ module PracticalDeveloper top_routes << route end ReservedWords.all = [ReservedWords::BASE_WORDS + top_routes].flatten.compact.uniq - - # Set up all profile attributes when the app starts - Profile.refresh_attributes! end end end