如何在模型中验证此字段:
<tr>
<th><%= f.label :Contacts, :class => 'control-label' %></th>
<td>
<%= select_tag "contacts[]", options_for_select(@contact.collect{|x| [x.firstname+" "+x.lastname ,x.id]}, @selected_array ), {:multiple => :multiple} %>
</td>
</tr>
我试过这个:
attr_accessor :contacts
validates :contacts, :presence => true
但它不起作用。