DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Creating A Select Box On A Table's Contents
<%= select('user', 'sites', Site.find_all.collect {|site| site.name}) %>




Comments
Snippets Manager replied on Thu, 2011/07/14 - 9:32am
Technomixx.comSnippets Manager replied on Thu, 2011/07/14 - 9:32am
<%= select 'user', 'sites', Site::find_all.collect( &:name ) %>http://technomixx.comRick Ross replied on Sat, 2008/05/17 - 10:33am
Snippets Manager replied on Wed, 2006/11/29 - 8:40am
Snippets Manager replied on Wed, 2006/11/29 - 8:40am
<%= collection_select :user, :sites, Site.find(:all), :id, :name %>This will generate a key-value pair of site.name and site.id in the select tag.Antonio Salazar replied on Sun, 2007/03/25 - 2:04pm
<%= select 'user', 'sites', Site::find_all.collect( &:name ) %>(The important part being the &:name, the others are just oddities of my style.)