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:
---------------------------------------------
#<Image:0xklasjdka> |
#<Image:0xklasb987> |
#<Image:0xkla9a8sd> |
#<Image:0xklasasjd> v
---------------------------------------------
* The desired end result should look like this:
---------------
top.jpg |
back.jpg |
left.jpg |
upper.jpg v
---------------
Can anyone tell me why I am getting this object back like this, and
how to fix it?
-truchty
( ps I am a rails n00b )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jean-François Trân
2008-Jan-22 15:44 UTC
Re: getting multiple select to work: options_for_select
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---