mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Allow to update SettingEntry via SettingEntry.code=
This commit is contained in:
parent
75d661b614
commit
6361a6ff49
1 changed files with 7 additions and 3 deletions
|
@ -27,9 +27,13 @@ class SettingEntry < ApplicationRecord
|
||||||
def self.method_missing(method, *args)
|
def self.method_missing(method, *args)
|
||||||
super(method, *args)
|
super(method, *args)
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
raise NoMethodError if method.to_s.include? '='
|
if method.to_s[-1] == "="
|
||||||
|
stg_code = method.to_s.sub("=", "")
|
||||||
SettingEntry.find_by!(code: method.to_s).retrieve
|
stg_value = args[0].to_s
|
||||||
|
SettingEntry.find_by!(code: stg_code).update(value: stg_value)
|
||||||
|
else
|
||||||
|
SettingEntry.find_by!(code: method.to_s).retrieve
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validators
|
# Validators
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue