There is another respond_to
for the usual case, and a special case when a param[:top]
is passed in, so there is another respond_to
earlier in the code:
respond_to do |format|
format.html { render :top_page_analytics }
format.json { render :json => @analytics }
format.xml { render :xml => @analytics }
return
end
but the above code actually gave a strange error for missing template for json, and further debug leading to:
respond_to do |format|
format.html { render :top_page_analytics }
format.json { render :json => @analytics }
format.xml { render :xml => @analytics }
end
return
which fixes the bug. The return is needed so that there will be no "double render error" because the program will flow to the other respond_to
. But I wonder the strange syntax of respond_to
, looking somewhat like a case statement, may cause error like that at the top?