# Passing params

**URL:** <https://www.ruby-forum.com/t/passing-params/123294>\
**Category:** Rails\
**Created:** [December 16, 2007, 1:58am UTC](https://www.ruby-forum.com/t/passing-params/123294 "2007-12-16T01:58:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 1:58am UTC](https://www.ruby-forum.com/t/passing-params/123294/1 "2007-12-16T01:58:48Z")

</div>

I am having a problem passing a variable from a test\_helper.rb to the  
controller test. I am parsing a string in the helper file and I am  
creating an array name @choose1. I can access the elements in @choose1  
in the view but I can’t in the controller. I thought global variables  
such as @choose1 could be accessed anywhere within the the test  
controller/view/helper. Does anyone know how this can be done?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 2:22am UTC](https://www.ruby-forum.com/t/passing-params/123294/2 "2007-12-16T02:22:09Z")

</div>

Any ideas?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 2:38am UTC](https://www.ruby-forum.com/t/passing-params/123294/3 "2007-12-16T02:38:28Z")

</div>

@choose1 is not a global variable, it is an instance variable. Global  
variables start with $.

I can’t really work out what you are trying to do though- could you  
post the helper method?

On Dec 16, 10:58 am, Hickman H. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 2:46am UTC](https://www.ruby-forum.com/t/passing-params/123294/4 "2007-12-16T02:46:42Z")

</div>

Thanks for the feedback though, I appreciate it

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 3:06am UTC](https://www.ruby-forum.com/t/passing-params/123294/5 "2007-12-16T03:06:35Z")

</div>

Problem solved… Initalize the variable in the application\_controller  
and set the contents in the test\_helper then you can access it anywhere  
you want

Dont know if its the best fix but it works

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 8:34am UTC](https://www.ruby-forum.com/t/passing-params/123294/6 "2007-12-16T08:34:58Z")

</div>

I’m confused. Are you trying to write a test? The only inputs to a  
controller action are the params, the session, and the database. No  
variables of any kind, global or not, are retained between controller  
actions, so why would you want to set one?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 2:46am UTC](https://www.ruby-forum.com/t/passing-params/123294/7 "2007-12-16T02:46:13Z")

</div>

could you post the helper method?

The helper method is extremely long. All I am trying to do is create an  
array inside test\_helper and be able to access it inside the  
test\_controller. I tried using $ and it doesn’t work.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 16, 2007, 9:05am UTC](https://www.ruby-forum.com/t/passing-params/123294/8 "2007-12-16T09:05:51Z")

</div>

kevin cline wrote:

> I’m confused. Are you trying to write a test? The only inputs to a  
> controller action are the params, the session, and the database. No  
> variables of any kind, global or not, are retained between controller  
> actions, so why would you want to set one?

No im not trying to write a test and what I thought was working wasn’t  
haha. Its called test\_controller because I am converting a written test  
to a computerized test. I am trying to make it so an administrator can  
type a simple string into a form and design a test by using simple tags  
that anyone would understand. Like a wiki but simpler. The clients I  
am doing it for barely know how to use a computer. I am parsing the  
string that they stored in the database to translate it into html and  
displaying a formatted page. The parser was a helper method and I am  
using AJAX to change parts of the page once it is loaded based on user  
input. It is a test for 3rd and 4th graders. I needed to be able to  
access an array that was initialized in test\_helper from the  
test\_controller. I thought it was working at first but what I had to  
end up doing was storing the array in a session variable to be able to  
access it in both places. Not sure if it is the best solution but it  
will work for now until I find a better one. Does that make sense?
