0

I am trying to use a dropdown in my edit.html.erb that is populated with a list of icon filenames (on the server). I used an array of label/value pairs to populate the list, which works great, except I want the dropdown to be preselected with the value that is currently in the record. When using collection_select with an actual model, the current value is selected. Do I have to create a tableless model instead of the array of structs to make this work?

1 Answer 1

1

you can use options_for_select (API) and pass value that you want to be selected as second argument

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.