I use Active Admin gem for Ruby on Rails. I have modules Team and Coach, which have a has_many and belongs_to relationship.
class Team < ActiveRecord::Base
belongs_to :coach
end
class Coach < ActiveRecord::Base
has_many :teams
end
I figured out how to display first name and last name on index and show page (i did it like that:)
index do
column :name
column "Coach" do |team|
team.coach.firstname + " " + team.coach.lastname
end
default_actions
end
What i want is how to display first name and last name of coach in Team form (new and edit page) in dropdown menu? Please help me with this.
Can you try this
f.input :coach_name, :as => :select, :collection => Coach.all.map {|u| [u.firstname, u.id]}, :include_blank => false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With