mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-31 04:32:06 +08:00
Fix update of database settings values [SCI-9240]
This commit is contained in:
parent
cc1d179366
commit
18072bbde7
1 changed files with 6 additions and 2 deletions
|
@ -1,14 +1,18 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Settings < ApplicationRecord
|
class Settings < ApplicationRecord
|
||||||
|
attr_accessor :merged_values
|
||||||
|
|
||||||
|
before_validation -> { self.values = merged_values || values }
|
||||||
|
|
||||||
def self.instance
|
def self.instance
|
||||||
first || new
|
first || new
|
||||||
end
|
end
|
||||||
|
|
||||||
def values
|
def values
|
||||||
merged_values = super
|
self.merged_values ||= super
|
||||||
self.class.instance_methods(false).grep(/^load_values_from_[A-Z0-9_]*/).each do |method|
|
self.class.instance_methods(false).grep(/^load_values_from_[A-Z0-9_]*/).each do |method|
|
||||||
merged_values = merged_values.merge(public_send(method))
|
self.merged_values = self.merged_values.merge(public_send(method))
|
||||||
end
|
end
|
||||||
merged_values
|
merged_values
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue