administrate icon indicating copy to clipboard operation
administrate copied to clipboard

How to customize the displayed text for an associated model?

Open marisawallace opened this issue 11 years ago • 4 comments

At https://administrate-prototype.herokuapp.com/admin/orders it looks like each order belongs to a Customer. This association is rendered nicely as:

prototype

Within my own app, I have a similar relationship: Student belongs to School. After setting up Administrate within my own app, I see the following out-of-the-box:

my prototype

Instead of displaying #<School:0x0000000aa98080> or similar, I want to customize the link text based on the attributes of that school model (similar to the prototype, which uses the Customer's full name). How can I do this? The docs at http://administrate-docs.herokuapp.com/ don't seem to cover this.

marisawallace avatar Nov 06 '15 13:11 marisawallace

@maxkwallace you're right - we need to add that to our docs. Right now, every model is displayed using its to_s method - you can define School#to_s to display whatever you like there.

c-lliope avatar Nov 06 '15 13:11 c-lliope

I'm going to close this issue for now - it overlaps a fair bit with #129. If you have any more questions around it, feel free to open it back up!

c-lliope avatar Nov 06 '15 13:11 c-lliope

@graysonwright Sounds good. Thanks for the tip!

marisawallace avatar Nov 06 '15 14:11 marisawallace

Thank you. I had this question too.

tquill avatar Feb 22 '16 04:02 tquill