In Rails, I have an array of hashes (@things) that looks something like this:
[
{"id"=>1, "name"=>"firstThing"},
{"id"=>2, "name"=>"secondThing"},
{"id"=>3, "name"=>"thirdThing"}
]
I also have an object with a thingId with a value of 2 (@otherThing.thingId = 2). I would like to turn the array into a dropdown with an empty option and with the secondThing option selected (because it has id = 2).
I successfully built this with some if, else and using that to output some <option value... code, then realized that's probably not the Railsy way to do it. Not sure exactly how to railsify this the best way. I have reviewed the documentation at http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html, but I'm not sure how my array of hashes fits in with all of that.