# Select doenst pass the correct value

**URL:** <https://www.ruby-forum.com/t/select-doenst-pass-the-correct-value/111725>\
**Category:** Rails\
**Created:** [August 10, 2007, 5:06am UTC](https://www.ruby-forum.com/t/select-doenst-pass-the-correct-value/111725 "2007-08-10T05:06:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coelho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9c0ed/32.png) [@coelho](https://www.ruby-forum.com/u/coelho)\
**Post date:** [August 10, 2007, 5:06am UTC](https://www.ruby-forum.com/t/select-doenst-pass-the-correct-value/111725/1 "2007-08-10T05:06:31Z")

</div>

Hello,

I have in my view a select tag that doesnt return the right value, could  
anyone point me what am I doing wrong?

Heres whats in my view

\<%=select “”, “situacao”, {“Open”=\>0,“Closed”=\>  
1},:include\_blank=\>true%\>

Then in my controller I do this

def status  
if request.post?  
#Do some stuff  
@situacao = params[:situacao]  
#some more code  
end  
end

The problem is that params[:situacao] always returns 0, even when I pick  
“Closed”  
Any help?

coelho

---

<div class="post-metadata">

**Author:** ![coelho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9c0ed/32.png) [@coelho](https://www.ruby-forum.com/u/coelho)\
**Post date:** [August 10, 2007, 12:08pm UTC](https://www.ruby-forum.com/t/select-doenst-pass-the-correct-value/111725/2 "2007-08-10T12:08:07Z")

</div>

Hi,

coelho coelho wrote:

> \<%=select “”, “situacao”, {“Open”=\>0,“Closed”=\> 1},:include\_blank=\>true%\>

What is the empty string for? If you put something into it,

\<%=select “foo”, “situacao”, {“Open”=\>0,“Closed”=\>  
1},:include\_blank=\>true%\>

you can use

@situacao = params[:foo][:situacao]

Lutz

---

<div class="post-metadata">

**Author:** ![coelho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9c0ed/32.png) [@coelho](https://www.ruby-forum.com/u/coelho)\
**Post date:** [August 11, 2007, 3:07am UTC](https://www.ruby-forum.com/t/select-doenst-pass-the-correct-value/111725/3 "2007-08-11T03:07:19Z")

</div>

Hi Lutz

Thank you, it worked fine the way said

> \<%=select “foo”, “situacao”, {“Open”=\>0,“Closed”=\>  
> 1},:include\_blank=\>true%\>

But now in the same form I have a date select that is always returning  
nil …

Data Inicio  
\<%= date\_select(“foo”, “data\_ini”, :order=\>[:day, :month, :year]) %\>

whats wrong there?

Coelho
