Cummings.P Cummings.P - 2 years ago 157
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 Source

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
  render nothing: true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download