Reputation: 8740
f.input :country_id, :prompt => 'Select Country', :as => :select, :collection => Country.all.map{|m| [m.name, m.id]} }
How to make one of the options from dropdown to be preselected. For example to select the value with id 5 what should be done?
Upvotes: 3
Views: 1500
Reputation: 2659
Try this,
f.input :country_id, label: 'country', :as => :select, :collection => Country.all.map{|m| [m.name, m.id]},include_blank: false
just include 'include_blank:' parameter
Hope its work
Upvotes: 4