Move back from after_initialize to explicit call (#11881)

This commit is contained in:
Michael Kohl 2020-12-15 05:16:27 +07:00 committed by GitHub
parent 1e0c53811d
commit 09fc23fd56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -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)

View file

@ -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