title: How can I load a embedded ruby javascript file on pageload?
body: <p>So, as I am sure you are all familiar with, you can have actions in Rails that call html.erb files. You can also set up actions to render remotely that call embedded ruby files (for example submitting a "post" form to the "posts" controller, handling it remotely, and calling a js.erb file to update elements in the page).</p>
  
  <p>What I want to know is how to run a js.erb file when I'm running an action that loads a template (html.erb file). To explain, consider if I want to run a User Show page:</p>
  
  <pre><code> class UsersController &lt; ApplicationController
     def show
       @user = User.find(params[:id])
     end
   end
  </code></pre>
  
  <p>Linking to <code>user_path(User.find(1))</code> will load <code>show.html.erb</code>, and all seems great.</p>
  
  <p>But what if I want to click on a link to <code>user_path(User.find(1))</code> and load <code>show.html.erb</code> while also loading <code>show.js.erb</code>? If (and I hope it is) this is possible, how could I adapt the show definition to also load <code>show.html.erb</code> and <code>custom_js_file_name.js.erb</code>?</p>
  
  <p>FYI: I'm using Rails 3.0.9 and 3.1.3 on two different applications, and assume that I would put <code>show.js.erb</code> or any others in the Users folder (<em>views/users/...</em>)</p>