title: Ruby On Rails: using arrays with link_to
body: <p>I was curious on how to use arrays in the link_to method in ruby on rails for example:</p>
  
  <p>Controller:</p>
  
  <pre><code>def index
      @test = [1,2,3]
  end
  </code></pre>
  
  <p>View:</p>
  
  <pre><code> &lt;%= link_to "test", {:action =&gt; 'index'}, :test =&gt; @test %&gt;
  </code></pre>
  
  <p>When looking at the source then, I end up with something to the effect of:</p>
  
  <pre><code>&lt;a href="/index/" test="123"&gt;test&lt;/a&gt;
  </code></pre>
  
  <p>My guess is that the array's to_string or something similar is getting called to set the value of test in the html.</p>
  
  <p>My goal is to be able to have a form in which people can submit data on the page, and then once they've submitted the data and return to the page, if they click on the link the data will persist through clicking on the link.</p>
  
  <p>*Ideally I would like to do this without having to pass the parameters in the url.</p>
  
  <p>Thank you.</p>