Open
Description
Context
The format_using
option is useful for formatting the output of a field, but it applies to both display and edit views. This often requires conditional logic to ensure proper behavior in different contexts. For example:
field :item, as: :text, format_using: -> {
view.display? ? link_to(value, record.item_link, target: "_blank") : value
}
To simplify this, lets introduce a decorate
option. This would function similarly to format_using
, but only apply to display views (e.g., Show and Index), keeping the edit form unaffected.
With decorate
, the same behavior could be achieved more cleanly:
field :item, as: :text, decorate: -> {
link_to(value, record.item_link, target: "_blank")
}
Metadata
Metadata
Assignees
Type
Projects
Status
In Progress