I'm running the latest Rails 2-3-stable branch (currently 2.3.3).
I'm using JQuery to post an AJAX request to my 'create' action, in which I have the following block:
respond_to do |format|
format.js
end
I have created create.js.erb
and to test this action, I've added the following single line:
alert('hello');
The request correctly enters the format.js block, but the response attempts to render a layout. Here's my log:
Jul 22 20:44:27 [2970] INFO: Rendering template within layouts/application
Jul 22 20:44:27 [2970] INFO: Rendering contacts/create
If I change my respond_to
block to the following, it works:
respond_to do |format|
format.js { render :layout => false }
end
Is this expected behaviour or is this a bug in Rails? I would have thought the fact that I'm rendering a JS response would be enough to set layout to false.