scinote-web/app/models/concerns/settings_model.rb

17 lines
313 B
Ruby
Raw Normal View History

2021-04-08 23:40:16 +08:00
# frozen_string_literal: true
module SettingsModel
extend ActiveSupport::Concern
included do
serialize :settings, JsonbHashSerializer
after_initialize :init_default_settings, if: :new_record?
end
protected
def init_default_settings
2021-04-08 23:40:16 +08:00
self.settings = self.class::DEFAULT_SETTINGS
end
end