In select_tag, using options_from_collection_for_select , how to set selected element in select box element in ruby on rails
select_tag "server", options_from_collection_for_select(@server, "id", "name")
like selected=”selected” set for an option
In
select_tag, when you useoptions_from_collection_for_selectuse fourth parameter ofoptions_from_collection_for_selectthat is value(id in your example) to be selectedIn the above example, 2 is selected id, you can put id of which option you wish to select in select_tag
For more information ref link below
http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_from_collection_for_select
Cheers!