title: Passing Rails Object to Javascript
body: <p>I have been working with Rails for a little while now. I got some stuff figured out, but I am struggling with this. I have an array of blog posts, rendered with just their title. In the controller the object looks simply like:</p>
  
  <pre><code>@articles
  </code></pre>
  
  <p>On my main page I render it through a partial and display just the title. </p>
  
  <pre><code>&lt;%= render 'shared/article_view', :collection =&gt; @articles %&gt;
  </code></pre>
  
  <p>This gives me a list of articles on the main page. When I click on the title I would like to open it up in a separate <code>div</code>. I have this working with a form. However, I'm not sure how to pass a parameter to the javascript that is getting called. I'm assuming I could pass the <code>id</code> to my <code>view_article.js.erb</code> file and could from there call </p>
  
  <pre><code>@article = Article.find_by_id(id)
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>&lt;p&gt;&lt;%= @article.text %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>However, I have no idea how to pass any sort of parameter to this file. It may not even work and I could be entirely wrong in doing this. As I said, still learning. Anyway, thanks for the help!</p>