Rails check for a .js template instead of .rjs?

respond_to do |format|
  format.html
  format.js { render :template => "login" }
end

Whenever I send an AJAX request to the action that has that code it says
it cant find the template login.js. Why isnt it looking for login.rjs?
Also when I take out the render it serves up the rhtml template instead
of the rjs template. Any idea why this is? I am using edge rails and the
latest version of mongrel.

respond_to do |format|
format.html
format.js { render :template => “login” }
end

Whenever I send an AJAX request to the action that has that code it says
it cant find the template login.js
. Why isnt it looking for login.rjs?
Also when I take out the render it serves up the rhtml template instead
of the rjs template. Any idea why this is? I am using edge rails and the
latest version of mongrel.


Posted via http://www.ruby-forum.com/.

An AJAX request is NOT a javascript request, it’s a HTML request. You’ll need to request the js by suffixing it with .js.

http://url/login.js

Actually Ryan, AJAX is a javascript request (Async Javascript And XML). I use format.js quite extensively in one of my projects to differentiate from local AJAX and external XML requests.

Jason