title: Rails unable to access instance variable in .js.erb file
body: <p>I'm making an ajax request and when it's complete i'm trying to add a div to the page. For some reason, i am unable to get instance variables to work in a .js.erb file.</p>
  
  <p>I have this controller method that gets called</p>
  
  <pre><code> # PUT /applications/1
    # PUT /applications/1.json
    def update
      @application = Application.find(params[:id])
      @current_app = params[:application]
      @curr_app_id = params[:id]
      @current_app.values.each do |key, val|
          key.values.each do |k,v|
              @curr_app_field_name = k[:field_name]
              @curr_app_field_value = k[:field_type]
          end
      end
  
      respond_to do |format|
        if @application.update_attributes(params[:application])
          format.html { redirect_to @application, notice: 'Application was successfully updated.' }
          format.json { head :no_content }
          format.js
        else
          format.html { render action: "edit" }
          format.json { render json: @application.errors, status: :unprocessable_entity }
          format.js
        end
      end
    end
  </code></pre>
  
  <p>which renders this .js.erb file</p>
  
  <pre><code>console.log('name = '+&lt;%= escape_javascript @curr_app_field_name %&gt;); // line 1
  console.log('test'); // line 2
  </code></pre>
  
  <p>But when i leave the instance variable in there, i don't get any output in firebug. I can see in the post request that the console.logs get generated with the correct field name, but nothing appears in the firebug console.</p>
  
  <p>If i remove line 1 completely, it works. </p>
  
  <p>How can i make it so i can access some variables in a .js.erb file?</p>