about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-02-12 07:19:15 +0100
committerGitHub <noreply@github.com>2021-02-12 07:19:15 +0100
commit15ced8728ff89932e3f8febf119f63c78ac9a960 (patch)
tree80fd9ee7c77e487830806d33b8adcc643076bae3
parentf8972d45032dce3f026a57cc3bdcafe4c0ab89d9 (diff)
Refactor Api::Web::SettingsController (#15717)
-rw-r--r--app/controllers/api/web/settings_controller.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/controllers/api/web/settings_controller.rb b/app/controllers/api/web/settings_controller.rb
index 3d65e46ed..601e25e6e 100644
--- a/app/controllers/api/web/settings_controller.rb
+++ b/app/controllers/api/web/settings_controller.rb
@@ -2,17 +2,16 @@
 
 class Api::Web::SettingsController < Api::Web::BaseController
   before_action :require_user!
+  before_action :set_setting
 
   def update
-    setting.data = params[:data]
-    setting.save!
-
+    @setting.update!(data: params[:data])
     render_empty
   end
 
   private
 
-  def setting
-    @_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
+  def set_setting
+    @setting = ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
   end
 end