Tosbourn iconTosbournSep 1, 2026 ~2 min source read

How to control model display names in Active Admin

Two practical ways to change which attribute Active Admin uses when rendering a model name: add a display_name method on the model, or change Active Admin’s lookup order to prefer a custom method.

Adding more display names to Active Admin

Share this story

Send the public story page.

Useful takeaways from this story.

You can customize the list of methods Active Admin tries by setting config.display_name_methods in config/initializers/active_admin.rb.

Define a custom method (for example active_admin_display_name) and make it the first entry in config.display_name_methods to avoid conflicts with other app behavior.

Adjusting the lookup order is useful when your app already has a display_name attribute or when existing to_s/name behaviors are unsuitable.

# Problem Active Admin automatically chooses how to show a model when it needs a human-readable label (for example in dropdowns or resource headings). By default it looks for a few methods on the model and falls back to a generic "ModelName #id" if none match. That can be fine for many apps, but causes issues when your model has a name attribute that needs different formatting in the admin, or when a display_name attribute exists but is sometimes nil.

# Solutions There are two straightforward approaches you can use without changing Active Admin itself.

1) Add a display_name method to the model

  • Return the formatted string that should be used in admin UI

Use this when you want a single, consistent admin label and you can modify the model directly.

2) Customize Active Admin's lookup order

If you can't or don't want to alter the model's existing display_name/name/to_s behavior, change the order of methods Active Admin checks. In config/initializers/active_admin.rb set config.display_name_methods to the array of method names you want Active Admin to try, in order.

  • Add a custom method name (active_admin_display_name) that returns the intended admin label.
  • Override Active Admin's defaults with: config.display_name_methods = %i[active_admin_display_name display_name name to_s]

This makes active_admin_display_name take precedence. If it returns nil or is not defined, Active Admin moves to display_name, then name, then to_s.

# Why you'd pick each approach

  • Add display_name on the model when you own the model code and want a single method name to represent display across the app.
  • Customize config.display_name_methods when the model already exposes attributes or methods used elsewhere, or when you need a different admin-only representation without touching existing methods.

# Example model method (idea only)

# Practical notes

  • If an attribute like display_name exists but is sometimes nil, Active Admin will fall back to the next available method. That can produce labels like "ModelName #1234", so prefer the config override or a dedicated active_admin_display_name to avoid that fallback.

# Short checklist

  • If you can change the model: implement display_name.
  • If you need admin-specific behavior: add active_admin_display_name and update config.display_name_methods to prefer it.
  • Test lists and dropdowns where model labels are used to confirm the new strings appear.

More context around this story.

Filtering select boxes in Active Admin
Tosbourn iconTosbournSep 1, 2026

Filtering select boxes in Active Admin

Originally appeared on Tosbourn – Belfast based Ruby developers . On a recent project we needed Active Admin to show a dropdown box that automatically updated depending on other selections happening on a form. This isn’t supported out of the box by Active Admin, but is quick to add yourself. Bonus points, we get to use

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app