Skip to content

Extract helper to format values in attr table#295

Merged
jonallured merged 1 commit intomainfrom
extract-helper-for-attrs-table-formatting
Feb 24, 2026
Merged

Extract helper to format values in attr table#295
jonallured merged 1 commit intomainfrom
extract-helper-for-attrs-table-formatting

Conversation

@jonallured
Copy link
Copy Markdown
Owner

Prior to this PR the formatting of values in the attr tables used in the CRUD pages section were spread out into the various models. For example, any timestamps would be formatted in the model file with a call to .to_fs and if there was a value that could be nil then I had to use the safe navigation operator. This was silly!

What this PR does is extract a helper method called attr_table_value that takes the value and then applies this logic:

  • if it is nil then return NIL
  • if it is a date or time then call to_fs on it
  • if it is an integer then format it with commas
  • otherwise just return the value

This really cleaned things up and relocated the formatting to the view layer rather than the model layer. It also gives me a single place to change these things should I so desire. Foreshadowing!

@jonallured jonallured enabled auto-merge (rebase) February 24, 2026 16:09
@jonallured jonallured merged commit 0540053 into main Feb 24, 2026
1 check passed
@jonallured jonallured deleted the extract-helper-for-attrs-table-formatting branch February 24, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant