Open geekelo opened 1 month ago
This ActiveAdmin configuration sets up an admin interface for managing LoanTransaction
records. The interface is designed to allow for viewing and updating existing records while preventing the creation or deletion of records. Here's a detailed explanation:
menu parent: 'Loans & Insurance', label: 'Loans'
:
LoanTransaction
resource under the "Loans & Insurance" menu in the ActiveAdmin dashboard with the label "Loans."actions :all, except: [:new, :create, :destroy]
:
index
, show
, edit
, update
) except for new
, create
, and destroy
. Admins can view and edit existing loan transactions, but they cannot create new ones or delete existing ones.includes :user, :transfer
:
user
and transfer
records in the query, which can help optimize the queries by reducing the number of database calls when displaying related data in the index view.config.sort_order = 'created_at_desc'
:
LoanTransaction
resource. The records will be sorted by the created_at
field in descending order, showing the most recent transactions first.permit_params :order, :order_date, :product_slug, :order_key, :status, :active
:
index do
:
This block defines how the LoanTransaction
records will be displayed in the index view.
Columns:
selectable_column
: Adds checkboxes to each row for batch actions.
id_column
: Displays the ID of each LoanTransaction
.
column :user
: Displays the associated user for each transaction.
column 'Interest' do |loan_transaction|
: Custom column displaying the interest associated with the loan transaction.
column :transfer
: Displays the associated transfer record.
column :status
: Displays the status of the transaction.
column :active
: Displays whether the transaction is active.
column :order
: Displays the order associated with the transaction.
column 'Loan Item' do |loan_transaction|
: Custom column displaying the product_slug
(the loan item).
column :order_date
: Displays the date the order was made.
column :created_at
: Displays the date the transaction was created.
column :updated_at
: Displays the date the transaction was last updated.
actions
: Adds standard edit, view, and delete actions to each row, though delete actions are disabled by the actions
configuration.
This ActiveAdmin configuration provides a well-structured interface for viewing and managing LoanTransaction
records. Admins can filter and sort through transactions, view detailed information, and edit records as needed. By excluding actions such as creating or deleting records, the configuration ensures that only existing data can be managed, which may be a deliberate choice to maintain data integrity for loan transactions.
FILE