I have an input which I render :as => :select. I would like one option to be selected as default. How would I go about that?
Thanks, Hendrik
If you are not making a form off of a model.
= semantic_form_for :report do |f|
= f.inputs name: 'Choose a Report Year' do
= f.input :report_year, collection: options_for_select(['2010', '2011', '2012', '2013'], '2012')
= f.action :submit, label: 'Submit Year', as: :button
So set a preselected answer you have to associate your object with the desired value.
countries = ['USA','Germany']
@user.country = countries.first
That works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With