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? -- Posted via http://www.ruby-forum.com/.
Maurício Linhares
2009-Jun-01 18:09 UTC
Re: collection_select option with multiple symbols
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 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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? > -- > Posted via http://www.ruby-forum.com/. > > > >