I have this piece of code:
= f.input :category, :as => :select, :label => false, :collection => Choices[\"Categories\"]
Choices[\"Cate
To remove a blank field from select it is necessary to show the selected so add selected: 1
Then set prompt to anything like prompt: "Please Select"
The final output will be
<%= select("social_links",:option_id, Option.all.collect {|p| [ p.name, p.id ] },{ selected: 1 , prompt: "Please Select"}, { class: 'form-control' , required:true})%>
You can pass a include_blank: false, include_hidden: false
option:
= f.input :category, :as => :select, :label => false, :collection => Choices["Categories"], include_blank: false, include_hidden: false
or you can customize call back action in your model to remove any empty string in the array parameter, assuming a parameter with the name "types":
before_validation :remove_empty_string
def remove_empty_string
types.reject! { |l| l.empty? }
end