1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Move merchants to top-level namespace (#895)

This commit is contained in:
Zach Gollwitzer 2024-06-20 08:38:59 -04:00 committed by GitHub
parent 2681dd96b1
commit dc3147c101
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 153 additions and 145 deletions

View file

@ -0,0 +1,41 @@
class MerchantsController < ApplicationController
layout "with_sidebar"
before_action :set_merchant, only: %i[ edit update destroy ]
def index
@merchants = Current.family.merchants.alphabetically
end
def new
@merchant = Merchant.new
end
def create
Current.family.merchants.create!(merchant_params)
redirect_to merchants_path, notice: t(".success")
end
def edit
end
def update
@merchant.update!(merchant_params)
redirect_to merchants_path, notice: t(".success")
end
def destroy
@merchant.destroy!
redirect_to merchants_path, notice: t(".success")
end
private
def set_merchant
@merchant = Current.family.merchants.find(params[:id])
end
def merchant_params
params.require(:merchant).permit(:name, :color)
end
end