1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 15:19:38 +02:00
Maybe/app/controllers/account/entries_controller.rb

27 lines
595 B
Ruby
Raw Normal View History

class Account::EntriesController < ApplicationController
layout :with_sidebar
before_action :set_account
def index
@q = search_params
@pagy, @entries = pagy(entries_scope.search(@q).reverse_chronological, limit: params[:per_page] || "10")
end
private
def set_account
@account = Current.family.accounts.find(params[:account_id])
end
def entries_scope
scope = Current.family.entries
scope = scope.where(account: @account) if @account
scope
end
def search_params
params.fetch(:q, {})
.permit(:search)
end
end