Forum: Ruby on Rails problem with options_from_collection_for_select() need id no

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
brutyn_nick (Guest)
on 2005-12-01 11:39
(Received via mailing list)

i need a select list with a id property and not name, cuz i just ajax
with this
list and it checks on id not name

if #called by ajax
	if @request.xml_http_request? #called by ajax
		@geotag_id=params[:geotag_id].nil? ? -2 : params[:geotag_id]
		@geotag_id=params[:geotag][:id].blank? ? -1:params[:geotag][:id]
	@geotag_id = -1

i use this

@geotags = Geotag.find(:all, :conditions =>['firm_id = ? and client_id =
? ',
firm_id, client_id])
@geotag_options = @geotags.collect {|g| [g.address1 + ", " + g.address2
+ ", "
+g.floor + ", " + ,]}

<%= select("geotag", "id", @geotag_options) %><br/>

<select name="geotag[id]">
<option value="%">All</option>
<option value="1">Foster Park 2, Brugge (VME Complex Foster)</option>
<option value="8">Foster Park 4, Brugge (VME Complex Foster)</option>
<option value="5">Gistelsteenweg 1, Brugge (Odevaere (VME
<option value="12">Molenaarsstraat 24, Oostende (Gevens)</option>
<option value="11">Rederskaai 39, Zeebrugge (VME Complex

but no id tag

i can work with this, here i got an id and the submit works

<select id="geotag_id" name="geotag_id">
<%= options_from_collection_for_select(@geotags, "id", "address1") %>

but i also need address2 and floor, and this seems not to work

<select id="geotag_id" name="geotag_id">
<%= options_from_collection_for_select(@geotags, "id", "address1" +
"address2" +
"floor") %>

can anyone help me?
This topic is locked and can not be replied to.