Sylar
Sylar

Reputation: 12072

Associate a Readable User Dropdown in ActiveAdmin

I guess not much help here. When you are trying to associate a user from a dropdown list, and imagine if you have 1000000 users, you would see the user instance. I need it to show the actual user's email address.

enter image description here

app/models/user.rb:

has_one :company

app/models/company.rb:

belongs_to :user

The link I was given has nothing to do with the dropdown's value.

Have I setup my rails association incorrectly? Funny thing was, using rails admin I had no issue in this department as I could associate a company when creating a user but not so with active admin.

All I want is when I select the User dropdown, as in picture, I'd see a list of user email addresses.

Upvotes: 3

Views: 174

Answers (1)

Sylar
Sylar

Reputation: 12072

Tim was correct all this time. I needed to create a function in the User model.

app/models/user.rb:

def display_name
 email
end

Upvotes: 3

Related Questions