如何将2个字段显示为此rails select语句的文本:
<%= select_tag "test3", options_from_collection_for_select(Teamplayer.joins(:live_player), "playerid", :name) %>
因此,不仅仅是John Doe,我还得到了John Doe Maryland
换句话说,而不是玩家,我获得了球员学院
答案 0 :(得分:0)
例如,如果您希望在选择选项中显示名称和位置,则应该
<%= select_tag "test3", options_for_select(Teamplayer.joins(:live_player).where(:teamid => @ids).collect{|p| "#{p.name} #{p.location}"}) %>