Forum: Ruby on Rails collection_select option with multiple symbols

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cc1c1f4c3a354d578c709a602efa3b45?d=identicon&s=25 Aldo Italo (aldoitalo)
on 2009-06-01 19:44
i have this collection_select:

  <%= f.label :customer, t('admin.customers.index.items') %><br />
  <%= f.collection_select( :customer, @customers, :id, :surname, options
= {:prompt => t('admin.customers.index.item') } ) %>




and i want to obtain this in my html:

  ...... <option> surname name company </option> .......



i tryed:
  <%= f.label :customer, t('admin.customers.index.items') %><br />
  <%= f.collection_select( :customer, @customers, :id, :surname + :name
+ :company , options = {:prompt => t('admin.customers.index.item') } )
%>



but it isn't possible. ho can i do?
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-06-01 20:10
(Received via mailing list)
Here's how it would look like:

 <%= f.label :customer, t('admin.customers.index.items') %><br />
 <%= f.select( :customer, @customers.map {|c| ["#{c.surname} #{c.name}
- #{c.company}", c.id] } ) %>

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)



On Mon, Jun 1, 2009 at 2:44 PM, Aldo Italo
Cc1c1f4c3a354d578c709a602efa3b45?d=identicon&s=25 Aldo Italo (aldoitalo)
on 2009-06-01 20:18
muito obrigado :-)
This topic is locked and can not be replied to.