Use respond_with rather than respond_to.