Tag: standard
How to add a value to a select field in Ruby On Rails
by Lennart on Nov.15, 2008, under Ruby On Rails
I’ll just leave this here: When you fill a select box directly from a array returned by .find(:all) you can add more values tothe select box this way:
Controller:
@hosts = Host.find(:all).collect {|p| [p.name, p.id] }
@hosts << ["None", nil]
View:
<dd>
<%= f.select :linkedhost, @hosts %>
<%= error_message_on(:service, :linkedhost) %>
</dd>

