getting multiple select to work: options_for_select

Hi,

<%= select_tag 'image_id', options_for_select(Image.find(:all) {| an_image| [ an_image.name, an_image.id ] }), :multiple => true %></p>

* I am in a view, and I am trying to search the image table and make a multiple select box with each image's name. * Right now it is working, but I see this:

Jerzy :

<%= select_tag 'image_id', options_for_select(Image.find(:all) {| an_image| [ an_image.name, an_image.id ] }), :multiple => true %></p>

You're attaching a block to Image.find that doesn't need one. You should chain with a map method like that :

Image.find(:all).map { |an_image| [ an_image.name, an_image.id ] }

You can use script/console to find the right expression and have instant feedback.

   -- Jean-François.