Josh Peek recently commited http://github.com/rails/rails/commit/148aff2097890a81e874a7c60bae5fa3b2a4d1fd
“Set template_format to html inside rjs templates so renders within it default to html.”
This broke controller actions like this:
def show
render :partial => ‘item’ if request.xhr?
end
This action would render default template on ordinary requests and a “_item.html.erb” partial on XHR requests.
After this commit, if there’s an XHR request this raises an exception that “_item.erb” can’t be found. It probably discards the “html” format template because the request is in “js” format. Workarounds are these:
def show
respond_to do |format|
format.html { render :partial => ‘item’ if request.xhr? }
end
end
or:
def show
@template.template_format = ‘html’
render :partial => ‘item’ if request.xhr?
end
Both of these make sense because they kinda explicitly state that they don’t care if the request was “js” format, they will respond in “html” anyway.
So my question is, was this breakage deliberate? Was the way I rendered HTML partials before wrong?