1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00
Maybe/app/controllers/transactions/categories_controller.rb
Jakub Kottnauer 9549182462
Add Transaction Merchant management (#686)
* Add basid crud for merchant management

* Tweak UI and add localization

* Fix lint

* Add filtering by merchant

* Add tests

* Add stimulus controller to update avatar in merchant form

* Add line between merchant rows

* Change default merchant color

* Cleanup
2024-04-29 15:17:28 -04:00

37 lines
918 B
Ruby

class Transactions::CategoriesController < ApplicationController
before_action :set_category, only: [ :update, :destroy ]
def index
end
def create
if Current.family.transaction_categories.create(category_params)
redirect_to transactions_path, notice: t(".success")
else
render transactions_path, status: :unprocessable_entity, notice: t(".error")
end
end
def update
if @category.update(category_params)
redirect_to transactions_path, notice: t(".success")
else
render transactions_path, status: :unprocessable_entity, notice: t(".error")
end
end
def destroy
@category.destroy!
redirect_to transactions_path, notice: t(".success")
end
private
def set_category
@category = Current.family.transaction_categories.find(params[:id])
end
def category_params
params.require(:transaction_category).permit(:name, :color)
end
end