Entry Rendering#
All visible activity in Sure is stored as Entry records that delegate to one of three concrete entryable types via Rails delegated_type :
delegated_type :entryable, types: Entryable::TYPES, dependent: :destroy
The canonical type list is ["Valuation", "Transaction", "Trade"], defined in the Entryable concern.
Dispatch Layer: _entry.html.erb#
app/views/entries/_entry.html.erb is the single dispatch point for every rendered entry. It calls entry.entryable.to_partial_path — provided by Rails' delegated_type — to resolve the correct type-specific partial, then forwards a fixed set of locals :
| Local | Default | Purpose |
|---|---|---|
entry | (required) | The Entry record |
balance_trend | nil | Sparkline / trend data for the row |
view_ctx | "global" | Controls display variations across UI contexts |
in_split_group | false | Indents and adjusts links for split-child rows |
Because to_partial_path is resolved on the entryable object, adding a new Entryable type automatically routes to its own partial without any changes to this dispatcher.
Type-Specific Partials#
Each entryable type owns its own partial and declares the same locals signature:
transactions/_transaction.html.erb— Renders the full transaction row: category icon / merchant logo, name link, tags, status pills (pending, duplicate, split), amount. Accepts all four locals.trades/_trade.html.erb— Renders a trade row. Acceptsentry,balance_trend, and a**splat for forwards-compatibility; does not act onview_ctx.valuations/_valuation.html.erb— Renders a valuation/balance anchor row. Acceptsentryplus a**splat.
view_ctx — Controlling Display Per Context#
view_ctx has two documented values:
"global"(default) — Used in the main transaction list (e.g.,transactions/_list.html.erb) where entries from multiple accounts appear together. Transfers display as+/- <amount>because the sign is ambiguous without account context ."account"— Explicitly passed in the per-account activity feed (accounts/show/_activity.html.erb) and theUI::Account::ActivityDatecomponent. Transfers render with a negated amount because the account perspective is unambiguous.
The view_ctx value flows from the caller → _entry.html.erb → type-specific partial without being altered.
in_split_group — Split Transaction Rendering#
Split parent entries are rendered via entries/_split_group.html.erb, which renders the parent row first then iterates over child entries, passing in_split_group: true . This local:
- Adds left-padding (
pl-8 lg:pl-12) to visually indent child rows . - Changes the entry's name link to
entry_path(entry, grouped: true). - Suppresses the split-child indicator icon when the child is already visually nested .
_split_group.html.erb accepts a view_ctx local (defaulting to "global") and forwards it to child entries, allowing split children to inherit the correct view context from their parent rendering location (e.g., account activity feed vs. transactions list) .
Key Files at a Glance#
| File | Role |
|---|---|
app/models/entry.rb | delegated_type declaration |
app/models/entryable.rb | TYPES constant; shared concern for all entryables |
app/views/entries/_entry.html.erb | Dispatch partial — resolves type and forwards locals |
app/views/transactions/_transaction.html.erb | Transaction row renderer |
app/views/trades/_trade.html.erb | Trade row renderer |
app/views/valuations/_valuation.html.erb | Valuation row renderer |
app/views/entries/_split_group.html.erb | Split parent + children group wrapper |
app/views/accounts/show/_activity.html.erb | Account activity feed — uses view_ctx: "account" |