title: Passing instance variable to js.erb file (Rails 3 / jQuery)
body: <p>I have an "index.html.erb" file with the following:</p>
  
  <blockquote>
    <p>&lt;%= render @users %></p>
  </blockquote>
  
  <p>This renders "_user.html.erb" and outputs a button for performing a certain action on each user:</p>
  
  <blockquote>
    <p>&lt;%= link_to "action", action_path(user), :id => "#{user.id}_action", :remote => true) %></p>
  </blockquote>
  
  <p>I've set up my User controller to respond to the AJAX request by looking at "action.js.erb". </p>
  
  <p>In order to perform javascript methods on particular users within the partial, and I'd like to know how instance variables from my partial (such as user.id) can be passed into or accessed within the js.erb file, for instance:</p>
  
  <pre><code>$("#{@user.id}_action").toggle();
  </code></pre>