How to add a value to a select field in Ruby On Rails
Posted by Lennart | Filed under Hacking, 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>
Tags: add, array, find, model, standard, value











