Cummings.P
Cummings.P

Reputation: 53

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~

Upvotes: 0

Views: 245

Answers (1)

jmschles
jmschles

Reputation: 274

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

Upvotes: 1

Related Questions