# Select question?

**URL:** <https://www.ruby-forum.com/t/select-question/189844>\
**Category:** Rails\
**Created:** [June 8, 2010, 7:18pm UTC](https://www.ruby-forum.com/t/select-question/189844 "2010-06-08T19:18:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [June 8, 2010, 7:18pm UTC](https://www.ruby-forum.com/t/select-question/189844/1 "2010-06-08T19:18:39Z")

</div>

view  
\<%= select( :order, :hcins, { “Man” =\> 3, “Is” =\> 5}) %\>  
(hcins is string value)

controller (order)

def create

@order =Order.new(params[:order])

@order.user = User.find(session[:user\_id])

@order.ucret= @order.hcins.to\_d \* @order.hboy

if @order.save  
redirect\_to :controller=\>“user”,:action =\>‘index’  
flash[:notice] = “Completed”  
else  
flash[:notice] = "Problem  
end

end

when I submit the form “hcins” gets “3 or 5” but I like to get text of  
selection(“man” or “is”) for “hcins” and values for “ucret” calculation.

how should I do it?

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [June 8, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/select-question/189844/2 "2010-06-08T19:39:50Z")

</div>

Lamer L. wrote:

> view  
> \<%= select( :order, :hcins, { “Man” =\> 3, “Is” =\> 5}) %\>  
> (hcins is string value)
> 
> controller (order)
> 
> def create
> 
> @order =Order.new(params[:order])
> 
> @order.user = User.find(session[:user\_id])
> 
> @order.ucret= @order.hcins.to\_d \* @order.hboy
> 
> if @order.save  
> redirect\_to :controller=\>“user”,:action =\>‘index’  
> flash[:notice] = “Completed”  
> else  
> flash[:notice] = "Problem  
> end
> 
> end
> 
> when I submit the form “hcins” gets “3 or 5” but I like to get text of  
> selection(“man” or “is”) for “hcins” and values for “ucret” calculation.
> 
> how should I do it?

Did you try …

\<%= select( :order, :hcins, [[“Man”, 3], [“Is”, 5]]) %\>

~Jeremy

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [June 8, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/select-question/189844/3 "2010-06-08T21:46:55Z")

</div>

> Did you try …
> 
> \<%= select( :order, :hcins, [[“Man”, 3], [“Is”, 5]]) %\>
> 
> ~Jeremy

yeah I tried and faced with same result.

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [June 9, 2010, 10:25am UTC](https://www.ruby-forum.com/t/select-question/189844/4 "2010-06-09T10:25:28Z")

</div>

On Jun 8, 6:18 pm, Lamer L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> view  
> \<%= select( :order, :hcins, { “Man” =\> 3, “Is” =\> 5}) %\>  
> (hcins is string value)

[…]

> when I submit the form “hcins” gets “3 or 5” but I like to get text of  
> selection(“man” or “is”) for “hcins” and values for “ucret” calculation.

If you need both the text and the numerical value then you need to  
store in your app the mapping of values to labels.

Fred
