Administrate: Change has_many or belongs_to display title

Created on 29 Dec 2015  路  5Comments  路  Source: thoughtbot/administrate

Is there currently a way to choose which attribute will be displayed in a has many and belongs to relationship form field?

Be happy to take a crack at it if not.

i.e. Change the text "Line Item #1001" to the Line Item's product attribute (see photo below).

product

Most helpful comment

@j-dexx

I think you can do the following to display a LineItem name

def display_resource(line_item)
  "#{line_item.name}"
end

All 5 comments

You just need to change the value returned for the display_resource method in your LineItemDashboard

Thanks @coneybeare been trying to find out how to do that.

@j-dexx

I think you can do the following to display a LineItem name

def display_resource(line_item)
  "#{line_item.name}"
end

@cameronbarker The commenters above are correct-- changing display_resource is the way to go.

馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sedubois picture sedubois  路  4Comments

drewtunney picture drewtunney  路  3Comments

Reedian picture Reedian  路  4Comments

ghost picture ghost  路  4Comments

amyin picture amyin  路  4Comments