Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

I'm trying to use options_from_collection_for_select to generate options
for a multiple select:
<select id="metro_area_states" name="states[]" size="10"
multiple="multiple">
<%= options_from_collection_for_select State.find(:all), :id, :name,
@metro_area.states %>
</select>
When selecting values for the first time, it works great. I use
@metro_area.state_ids= in the controller to set the selected states, and
it saves just fine.
When editing, it should pre-select the states using @metro_area.states,
but it doesn't. The docs for options_from_collection_for_select say it
uses the value parameter, :id in my case, to match against the
collection. I know @metro_area.states contains State objects. I can
output them just fine manually, but options_from_collection_for_select
doesn't like them.
Should I just do this manually myself, or is there a way to make this
work?