You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if we should be setting the Content-Type response header for JsonapiErrorable#handle_exception and JsonapiErrorable::Validatable#render_errors_for. In our app we've overwritten those two methods in our base API controller to look something like this:
# Override JsonapiErrorable#handle_exception to ensure correct content typedefhandle_exception(*)self.content_type ||= Mime[:jsonapi]superendprivate# Override JsonapiErrorable::Validatable to ensure correct content typedefrender_errors_for(*)self.content_type ||= Mime[:jsonapi]superend
Ah! Sorry I think you are saying - jsonapi-rails is handling this for normal responses, but since we avoid that gem for errors we should do it here too. Is that right? If so I agree, let's do it.
@richmolj Yes, the later. jsonapi-rails is setting the Content-Type for most responses, so we get that "for free." But since we're not using that gem for error responses, the response header is not being set.
Activity
richmolj commentedon May 21, 2018
Hey @stevenharman sorry for not seeing this issue earlier. It seems like we would want to do something like this globally, not just for errors, right?
richmolj commentedon May 21, 2018
Ah! Sorry I think you are saying - jsonapi-rails is handling this for normal responses, but since we avoid that gem for errors we should do it here too. Is that right? If so I agree, let's do it.
stevenharman commentedon May 23, 2018
@richmolj Yes, the later.
jsonapi-railsis setting theContent-Typefor most responses, so we get that "for free." But since we're not using that gem for error responses, the response header is not being set.richmolj commentedon May 23, 2018
We should take your fixes and put them into this lib then, I agree. Do you want to PR for that?