shorthand names/labels for associated models

17 views
Skip to first unread message

drewda

unread,
Dec 28, 2010, 8:29:14 PM12/28/10
to rails_admin
Hi all,

I've been enjoying rails_admin; one fewer reason I miss Django...
Anyways, I have a number of model associations that are currently
listed in the table view as (for example): "User #1" and "User #3".
I'd like to change the name so that instead of the automatic
"ModelName #ID", it's instead printing out "Model.FirstName
Model.LastName" or another custom combination. Can someone offer
guidance?

Thank you,
Drew

Scott Mills

unread,
Jan 5, 2011, 5:43:03 PM1/5/11
to rails_admin

It looks like it tries to use "name" and then "title" for the model
first before it uses "classname #". You could add a method like:

def title
FirstName + " " + LastName
end

Scott

drewda

unread,
Jan 5, 2011, 6:25:11 PM1/5/11
to rails_admin
Works well. Thanks, Scott!

Drew

Petteri Kääpä

unread,
Jan 18, 2011, 9:21:15 AM1/18/11
to rails_admin
I'm late with response, but in case someone else stumbles upon this:
Take a look at object_label method in RailsAdmin documentation if you
don't want to modify your ActiveRecord objects.

P.

drewda

unread,
Jan 21, 2011, 8:34:13 PM1/21/11
to rails_admin
Thanks, Petteri! I actually just finally noticed that in the docs
myself.

Drew
Reply all
Reply to author
Forward
0 new messages