Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the displayed text for an associated model? #175

Closed
marisawallace opened this issue Nov 6, 2015 · 4 comments
Closed

How to customize the displayed text for an associated model? #175

marisawallace opened this issue Nov 6, 2015 · 4 comments

Comments

@marisawallace
Copy link

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.

@c-lliope
Copy link
Contributor

c-lliope commented Nov 6, 2015

@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
Copy link
Contributor

c-lliope commented Nov 6, 2015

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 c-lliope closed this as completed Nov 6, 2015
@marisawallace
Copy link
Author

@Graysonwright Sounds good. Thanks for the tip!

@tquill
Copy link

tquill commented Feb 22, 2016

Thank you. I had this question too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants