I use the following static method in a site model to achieve something like this:
class Site
def self.select_options
Site.find(:all, :order => 'UPPER(name)').collect {|s| [s.name, s.id]}
end
def
Then in my domain I call:
<%= f.select :site_id, Site.select_options %>
This works well for these circumstances.
:
class CodesecureProject
def self.select_options
CodesecureProject.find(:all, :order => 'name').collect {|p| [p.name, p.id]}
end
end
:
<%= f.select :codesecure_project_id, CodesecureProject.select_options %>