I am trying to add a class to the select form helper, here is my code:

<%= f.select :manager_id, user.collect {|u| [u.username, u.id]}, :prompt => "Select manager 
username", :class => "btn btn-default dropdown-toggle" %>

But it didn't work, and is there an option to add multiple selection?

有帮助吗?

解决方案

Add the curly brackets for the hash. class is part of the last parameter. If you don't add the brackets, it goes as third

<%= f.select :manager_id, user.collect {|u| [u.username, u.id]}, {:prompt => "Select manager 
username"}, {:class => "btn btn-default dropdown-toggle", :multiple => true} %>

I haven't tried the multiple option in select. But it should work according to this post

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top