-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oat, Rails Responders and hypermedia mime types #50
Comments
Hi. Good catch. I'm not using renderers myself (I also found the docs to be lacking, so opted not to use an under-documented feature), but I can definitely see the value of this (better adapter swapping on a per-request level). Since Oat is not Rails-specific, I think this addition should belong in an hypothetical oat-rails gem, which I think has been discussed before elsewhere. |
There's so little code needed, that it doesn't seem to warrant that effort at this time. How about I just add a section to the README about rails integration? |
Good solution :) Appreciated. |
…g a Hypermedia mime type. Also helps resolve ismasan#50.
…g a Hypermedia mime type. Also helps resolve ismasan#50.
When doing the following in a Rails app (example)
Works great if the http request is json using the
Accepts: application/json
header or theformat=json
query parameter. However, if I request with the Siren mime type (Accepts: application/vnd.siren+json
orformat=siren
query parameter), it fails with a standard rails error saying it can't find a template for the siren format.After digging into it, the root of the problem is that the serializer needs to implement a
to_siren
method. If I add ato_siren
method to my serializer, then the responder block is called and all is well.I'm wondering if anyone is having success with Rails and using
respond_with SERIALIZER
AND also using the format's specific mime-type without implementing ato_FORMAT
method?Maybe I'm using responders incorrectly? I have not found any documentation that really explains how to do something like this for an API response without a template. I managed to find something that works thanks to the README in roar-rails
I'm thinking Oat should provide support for this. I've added such in my fork, but I want to verify it's not a problem localized to my app's specific implementation before I submit a PR.
The text was updated successfully, but these errors were encountered: