eatsleepcode
eatsleepcode

Reputation: 119

Rails 4 Make Default for f select null

I want to make the default option for my dropdown select in a form null. I added

{:include_blank => true}

but the initial blank option is not showing up.

Here's the line of code:

<%= f.select :user_ids, options_for_select(User.all.collect{|user| [user.name, user.id]}, @reservation.user_ids), {multiple: true, :class=>'user-id-widget', size: 5}, {:include_blank => true} %>

Upvotes: 0

Views: 1253

Answers (1)

Pavan
Pavan

Reputation: 33552

As per the select,you need to write :include_blank => true as an argument of html_options

This should work

<%= f.select :user_ids, options_for_select(User.all.collect{|user| [user.name, user.id]}, @reservation.user_ids), {multiple: true, :include_blank => true,:class=>'user-id-widget', size: 5} %>

Upvotes: 1

Related Questions