# Getting params from one view into another

**URL:** <https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815>\
**Category:** Rails\
**Created:** [January 12, 2008, 12:44pm UTC](https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815 "2008-01-12T12:44:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 12, 2008, 12:44pm UTC](https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815/1 "2008-01-12T12:44:58Z")

</div>

Hi Ruby Forum,

I have a situation that I have never run into before. I need to pass a  
param from one view into a different section of my controller.

I’m having a bit of trouble passing a variable from my view into another  
part of my controller in order to control what IP address is used to  
have the graph applied.  
I want to pass the IP address to the controller from the view as  
[:text1] in this example into “one” in my controller.

Normally, when I pass a param, it is used in the same part of the  
controller…ie, in this case: “view”…not in this case. I need to pass  
the param from the view page into “one” in order to see the graph I’m  
generating.

* * *

def view  
input = params[:text1]  
input.chomp  
@graph = open\_flash\_chart\_object(950,400, ‘/look/one’, false, ‘/’)  
end

def one  
@tester = Tester.find(:all, :conditions =\> "ipadd = ‘10.1.1.2’ and label

> ‘2008-01-01 00:00:00’", :order =\> ‘label’)  
> end

* * *

Is there a way to pass it from view into one?

thanks

jackster

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 12, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815/2 "2008-01-12T17:54:30Z")

</div>

Hi,  
in the view action, you can - “$input = params[:text1]” ; then in  
one action, fetch it out, such as " puts “this is s: #{s}” ".  
$input makes it as a global variable.  
Hope it solves your issue.

Br,  
Myst

On 1ÔÂ12ÈÕ, ÏÂÎç1Ê±44·Ö, jackster the jackle \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 12, 2008, 5:58pm UTC](https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815/3 "2008-01-12T17:58:43Z")

</div>

Hi,  
Two methods:  
1.  
in the view action, you can - “$input = params[:text1]” ; then in  
one action, fetch it out, such as " s = $input; puts “this is s: #{s}”  
".  
$input makes it as a global variable.  
2.  
you can build a “form” in the view.rhtml, and deliver the  
params[:text1] by this form to the next action “one”

Hope it solves your issue.

Br,  
Myst

On 1ÔÂ12ÈÕ, ÏÂÎç1Ê±44·Ö, jackster the jackle \<rails-mailing-l…@andreas-

On 1ÔÂ12ÈÕ, ÏÂÎç1Ê±44·Ö, jackster the jackle \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [January 12, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/getting-params-from-one-view-into-another/125815/4 "2008-01-12T18:44:11Z")

</div>

myst\_tt wrote:

> Hi,  
> Two methods:  
> 1.  
> in the view action, you can - “$input = params[:text1]” ; then in  
> one action, fetch it out, such as " s = $input; puts “this is s: #{s}”  
> ".  
> $input makes it as a global variable.  
> 2.  
> you can build a “form” in the view.rhtml, and deliver the  
> params[:text1] by this form to the next action “one”
> 
> Hope it solves your issue.
> 
> Br,  
> Myst
> 
> On 1ï¿½ï¿½12ï¿½ï¿½, ï¿½ï¿½ï¿½ï¿½1Ê±44ï¿½ï¿½, jackster the jackle \<rails-mailing-l…@andreas-
> 
> On 1ï¿½ï¿½12ï¿½ï¿½, ï¿½ï¿½ï¿½ï¿½1Ê±44ï¿½ï¿½, jackster the jackle \<rails-mailing-l…@andreas-

Both great ideas…thanks for helping me out with this

jackster.mobi
