# Getting parameter?

**URL:** <https://www.ruby-forum.com/t/getting-parameter/129731>\
**Category:** Rails\
**Created:** [February 21, 2008, 4:07am UTC](https://www.ruby-forum.com/t/getting-parameter/129731 "2008-02-21T04:07:22Z")\
**Posts on this page:** 9\
**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:** [February 21, 2008, 4:07am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/1 "2008-02-21T04:07:22Z")

</div>

Hello RoR developers

do you know how can I get parameter from selection to method from out of  
form object?  
I have selection in view page, I have method in controller and I want to  
get parameter from selection but selection is not in form. how can I get  
it ??

if you have sample code pls write it with your commend.

thank you very much for any help

---

<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:** [February 21, 2008, 5:41pm UTC](https://www.ruby-forum.com/t/getting-parameter/129731/2 "2008-02-21T17:41:40Z")

</div>

From [http://api.rubyonrails.org/](http://api.rubyonrails.org/) :  
select(object, method, choices, options = {}, html\_options = {})

that’s the basic select tag used to interact with a model…here’s one  
of my select forms in a view (inside a form tag of course)

\<%=select(:record, :station\_id, Station.find(:all).collect {|p|  
[p.name, p.id] }, { :selected =\> @station.id }) %\>

In this example I’m trying to set the station\_id method of my record  
object. I want to be able to select from all my stations  
(Station.find(:all)) then we collect those stations into a set option  
tags basically - the interior of the collect takes the text then the  
value of the option tag ( {|p| [p.name, p.id]} ).

Ok so that’s the select tag. Then we access the info from the select  
tag the same way we access any form parameter in the controller:

params[:object][:method]

or in my example:

params[:record][:station\_id]

this will get you the value of the option tag you setup in your select  
tag (be careful to get the correct info into the value and text of the  
option tags)

Hope that helps.

T

On Feb 20, 8:07 pm, Ibrahim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<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:** [February 22, 2008, 2:54am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/3 "2008-02-22T02:54:37Z")

</div>

> that’s the basic select tag used to interact with a model…  
> the basic select\_tag object is the form s object right ???

> Ok so that’s the select tag. Then we access the info from the select  
> tag the same way we access any form parameter in the controller:

I m trying to get params[:] from out of form. there is no form in my  
view page.

thank you very much again for your comment.

---

<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:** [February 22, 2008, 2:46am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/4 "2008-02-22T02:46:04Z")

</div>

thank you very much…

---

<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:** [February 22, 2008, 3:41am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/5 "2008-02-22T03:41:25Z")

</div>

I have solution for you.

Change your javascript to be storing your wanted params to cookies or  
session, you can use AJAX. I dont have this script but i have read about  
it. so you can access that params in your view without form or  
select\_tag. It was 3 days your problem posted without solution, it still  
continoes up to 7 days your should pay rails consultant for it. (~\_~!)

~_~_~_~_~_~_~_~_~_~_~_~_~_~  
Reinhart Ariando  
YM:Booking2Heaven  
WEB:teapoci.blogspot.com  
~_~_~_~_~_~_~_~_~_~_~_~_~_~

---

<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:** [February 22, 2008, 3:56am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/6 "2008-02-22T03:56:07Z")

</div>

actually I have many suggestions but I couldnt use any.  
ajax is another solution but nobody around me knows programming. no  
chance to consult with anyone. that s why I ask here. I don t have so  
much time left either. today I need to finish it. quick and certain  
solutions are preferred. 🙂

thank you very much for your suggestion.

---

<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:** [February 22, 2008, 4:31am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/7 "2008-02-22T04:31:00Z")

</div>

hey…why you not convert your js to your controller and store it in  
session you can make new def method for it or new attribute, it think  
it will be help full and make it has array or hash, then you can call  
freely in your view.

---

<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:** [April 14, 2008, 6:20am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/8 "2008-04-14T06:20:59Z")

</div>

I just wanna ask whether i can call a function from my view and pass  
some parameters within. For the example, i have function setDirections  
that when i call using “setDirections(“new york”, “boston”, “en\_US”);”  
command run smoothly… but what i need is to replace “new york” and  
“boston” with session[:address1] and session[:address2]…  
Do you have any opinion about this…???

Regards,

Adi

---

<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:** [February 22, 2008, 5:40am UTC](https://www.ruby-forum.com/t/getting-parameter/129731/9 "2008-02-22T05:40:48Z")

</div>

Visit Indonesia 2008 wrote:

> hey…why you not convert your js to your controller and store it in  
> session you can make new def method for it or new attribute,

could you tell me your suggestion detailed? I couldn t get it well.

thank you Ariando,you are so philanthropic.
