ruby on rails - select collection -- displaying more than 1 column value in the select list -


i have got following line of code in new player.html.erb file.

<% form_for @player, :html => { :multipart => true } |f| %>  team: <%=  f.select(:sub_team, [["--new--", "new"]] + team.all.collect {|p| [ p.bsr_team_name, p.bsr_team_id  ] }, {:include_blank => 'none', :selected => params[:teamid].to_i}) %>   ... <% end %> 

user can associate player team.

currently team field, drop down list displayed team names.

now need include 'team leader name' next team name in drop down list.

i tried following not seem work:

team: <%=  f.select(:sub_team, [["--new--", "new"]] + team.all.collect {|p| [ p.bsr_team_name -- p.bsr_team_leadername, p.bsr_team_id  ] }, {:include_blank => 'none', :selected => params[:teamid].to_i}) %> 

i grateful if give me hint how display team lead name next team name.

cheers

try this:

team: <%=  f.select(:sub_team, [["--new--", "new"]] + team.all.collect {|p| [ "#{p.bsr_team_name} -- #{p.bsr_team_leadername}", p.bsr_team_id  ] }, {:include_blank => 'none', :selected => params[:teamid].to_i}) %> 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -