Reputation: 2189
I created a FreeMeal
tab in my DB; this tab has a foreign key on the User
tab. When I use the form in Active Admin to create a new entry of FreeMeal, I get a list of all my users for the user input; but users aren't displayed the right way, like so:
edit: the form is automatically populated as I have the foreign key on users. I simply have the following code for this form in app/admin/free_meals.rb
:
ActiveAdmin.register FreeMeal do
form do |f|
f.inputs "FreeMeal" do
f.input :user
f.input :reason
end
f.actions
end
end
I would like to have this list with my users' id
, first_name
and last_name
.
How can I do that ?
Upvotes: 0
Views: 93
Reputation: 1713
Try this:
f.input :user, as: :select, collection: User.all.map{ |u| ["#{u.id}, #{u.first_name} #{u.last_name}", u.id]}, multiple: false
Upvotes: 1