Use before_action to pull up account assignment

This commit is contained in:
David Heinemeier Hansson
2025-11-02 16:04:44 +01:00
parent c834cce504
commit 02bd57089d
@@ -1,17 +1,21 @@
class Account::SettingsController < ApplicationController
before_action :ensure_admin, only: :update
before_action :set_account
def show
@account = Account.sole
@users = User.active.alphabetically
end
def update
Account.sole.update!(account_params)
@account.update!(account_params)
redirect_to account_settings_path
end
private
def set_account
@account = Account.sole
end
def account_params
params.expect account: %i[ name ]
end