我在
Ruby on Rails上使用Active Admin gem.
我有模块Team和Coach,它们具有has_many和belongs_to关系.
我有模块Team和Coach,它们具有has_many和belongs_to关系.
class Team < ActiveRecord::Base belongs_to :coach end class Coach < ActiveRecord::Base has_many :teams end
index do column :name column "Coach" do |team| team.coach.firstname + " " + team.coach.lastname end default_actions end
解决方法
你能试试吗?
f.input :coach_name,:as => :select,:collection => Coach.all.map {|u| [u.firstname,u.id]},:include_blank => false