internetee-registry/app/controllers/admin/accounts_controller.rb
2021-08-23 16:38:44 +03:00

34 lines
906 B
Ruby

module Admin
class AccountsController < BaseController
load_and_authorize_resource
def index
@q = Account.includes(:registrar).search(params[:q])
@accounts = @q.result.page(params[:page])
@accounts = @accounts.per(params[:results_per_page]) if paginate?
render_by_format('admin/accounts/index', 'accounts')
end
def show; end
def edit; end
def update
if @account.valid?
@sum = params[:account][:balance].to_f - @account.balance
action = Actions::AccountActivityCreate.new(@account, @sum, params[:description],
AccountActivity::UPDATE_CREDIT)
redirect_to admin_accounts_path, notice: t('.updated') if action.call
end
render 'edit'
end
private
def account_params
params.require(:account).permit(:id, :currency, :balance)
end
end
end