Cummings.P Cummings.P - 5 months ago 36
Ajax Question

Fixing ActionView::MissingTemplate without render nothing?

I ran into ActionView::MissingTemplate early on in my development, and used render nothing: true to fix it. It works great right now, the only thing is I have to send errors via a json render in some cases, and then I end up with a DoubleRenderError. I also understand that some use head: ok, but that is not working either. Is there an alternate way to deal with this error? Any and all help is appreciated. Cheers~

Answer

You should only get a DoubleRenderError if both render calls are getting hit, which you may be able to solve with a condition:

if errors.present?
  render json: errors
else
  render nothing: true
end
Comments