Search code examples
ruby-on-railsformsruby-on-rails-4

Select a blank option in the static drop-down rails form


I have a drop-down menu of a rails form which the user can have the option to choose between 1 to 5. And I want the drop-down to select the blank option at first.

So I tried this:

<%= f.select :point1, [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]], :include_blank => true %>

But it didn't work. Any idea?

Thanks!


Solution

  • Try this:

    <%= f.select :point1, options_for_select([[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), {:include_blank => true} %>