# Post problem with select lists

**URL:** <https://www.ruby-forum.com/t/post-problem-with-select-lists/51305>\
**Category:** Rails\
**Created:** [December 29, 2005, 9:19am UTC](https://www.ruby-forum.com/t/post-problem-with-select-lists/51305 "2005-12-29T09:19:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [December 29, 2005, 9:19am UTC](https://www.ruby-forum.com/t/post-problem-with-select-lists/51305/1 "2005-12-29T09:19:15Z")

</div>

hey,

i have this problem

how come i always get -1 for the select list??

rhtml

First, select a client.  
  
\<%= options\_for\_select(@client\_options, @client\_id.to\_i) %\>  
\<%= @client\_id %\>

controller  
if @request.post?  
if @request.xml\_http\_request? #called by ajax,  
@client\_id = -2  
else  
@client\_id = -11#params[:client][:id].nil? ? -11 :  
params[:client][:id]  
end  
else  
@client\_id = -1  
end

shouldnt it be-11 ???

Output  
First, select a client.

Select a client Twodecode -1

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [December 29, 2005, 11:28am UTC](https://www.ruby-forum.com/t/post-problem-with-select-lists/51305/2 "2005-12-29T11:28:54Z")

</div>

Hi Nick

I’d use the script\breakpointer to check what’s happening here (put a  
breakpoint instruction just above the line you want to check, and launch  
the  
breakpointer: you’ll be able to quickly inspect the variables and know  
exactly what happens).

Thibaut

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [December 29, 2005, 12:05pm UTC](https://www.ruby-forum.com/t/post-problem-with-select-lists/51305/3 "2005-12-29T12:05:09Z")

</div>

hmmm, doesnt seem to work

i cant find the problem, i made a lot a forms with ruby now, and this  
one cant i  
get to work :s:s

cant seem to get the value of [:client][:id] , it is always -1

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [December 29, 2005, 12:11pm UTC](https://www.ruby-forum.com/t/post-problem-with-select-lists/51305/4 "2005-12-29T12:11:11Z")

</div>

when i do inspect

\<%= params.inspect %\>  
{“action”=\>“access\_geotags”, “id”=\>“32”, “controller”=\>“users”}

and in the rhtml

 \<%= check\_box "user", "view\_all\_geotags" %\> User may view all geotags from the selected clients. Or, select the geotags the user can view. First, select a client. \<%= @client\_id.inspect %\> \<%= options\_for\_select(@client\_options, @client\_id.to\_i) %\> 

output of rhtml

 User may view all geotags from the selected clients. Or, select the geotags the user can view. First, select a client. 3 Select a client Belcompany BYS Twodecode 

in the controller

if @request.post?  
@client\_id = params[:client][:id].blank? ? -1 : params[:client][:id]  
else  
@client\_id = 3  
end

if @request.post?  
@user\_id = params[:id]  
@geotagidlist = params[:selected\_geotagtype].blank? ? -1 :  
params[:selected\_geotagtype]  
@user.update\_attribute(:view\_all\_geotags,  
params[:user][:view\_all\_geotags] )

end

the update works but i cant get the clientid :s:s:s
