administrate icon indicating copy to clipboard operation
administrate copied to clipboard

How to display has_many field name in edit/new dropdown

Open ragunaru opened this issue 8 years ago • 1 comments

I have a basic relationship model where a venue has many categories through categorization. All good and dandy. However, I would like to show the names of the categories when editing/adding new venues.

How it currently looks: image

My categories: image

Is there a way, without having custom view files, to change this?

ragunaru avatar Mar 21 '18 08:03 ragunaru

To answer my own question, you need to add a custom method in your dashboard of the model you need to change the display logic, like such:

  def display_resource(your_model)
    your_model.name # or whatever property you're trying to show
  end

So in my case I added this in my category dashboard.

Source: https://github.com/thoughtbot/administrate/blob/master/docs/customizing_dashboards.md#defining-labels

Tip for future self: RTFM.

ragunaru avatar Mar 21 '18 08:03 ragunaru