Refactor Api::Web::SettingsController (#15717)

lolsob-rspec
Eugen Rochko 2021-02-12 07:19:15 +01:00 committed by GitHub
parent 0baa928e56
commit ecfcdc856b
1 changed files with 4 additions and 5 deletions

View File

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