hcb
hcb copied to clipboard
Standardize model status fields
The AchTransfer model has status, status_text, status_text_long, state, and state_icon, and they all return different things!
https://github.com/hackclub/hcb/blob/4236fc109e38ecd8a623bd51cc63bb5300fa3353/app/models/ach_transfer.rb#L161-L195
I propose that every stateful model should have:
-
state, which returns the raw, unformatted state as a symbol (e.g.:deposited) -
state_color, which returns a CSS class for the color of the state badge (e.g.info) -
state_icon, an optional icon to display alongside the badge -
--- - An entry in
config/locales/en.ymlthat contains humanized states, e.g.
states:
ach_transfer:
pending: "Pending approval"
yes! I agree.
We should have a concern that:
- Implements a default version of
state,state_color, andstate_iconthatraise NotImplementedError. - If the concern detects that AASM is used, it can have a default implementation for
state(aasm_state.to_sym)
As for I18n, I wonder if Rails expects it under a certain key