title: Rails Ajax: .js.erb rendered as text, not JS
body: <p>I'm having a trouble with rails3 to render Javascript (If this is relevant, I use JQuery and it works fine since it's used in numerous other parts of the application) instead of html.</p>
  
  <p>What I have:
  I a view, I have this link:</p>
  
  <pre><code>&lt;%= link_to 'Edit', edit_user_repreneur_path(@user_repreneur, :format =&gt; :js), :remote =&gt; true %&gt;
  </code></pre>
  
  <p>First of all, I don't really get why I have to add :format => :js to get the controller to use the JS view, and not the HTML one.
  Here is the code of the controller:</p>
  
  <pre><code>def edit
      @user_repreneur = UserRepreneur.find_by_id_view(params[:id])
      respond_to do |format|
        format.js
        format.html
      end 
  end
  </code></pre>
  
  <p>At the beginning of the controller class, I have this line:</p>
  
  <pre><code>  respond_to :js, :html
  </code></pre>
  
  <p>My edit.js.erb file contains a single line with an alert.
  However, when rendering the page, the JS is rendered as text, and therefore is not executed.
  I tried to change the format.js line to</p>
  
  <pre><code>format.js { render :layout =&gt; false }
  </code></pre>
  
  <p>But it doesn't change anything.
  I guess I am missing something, but I really don't see what...</p>
  
  <p>Thanks a lot in advance, cheers!</p>
  
  <p>PS: I don't know if this is helpful, but before I add the  :format => :js bit in my link helper, the view was always rendered as HTML, and if I commented the format.html line, I had a 406 Not Acceptable error on the server side.</p>