-
Notifications
You must be signed in to change notification settings - Fork 420
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
Automatic lookup within Rails controllers #175
Comments
Yes this is not automatic yet. However #89 and other pull requests have made it a bit less verbose. This should work render json: WidgetSerializer.new(widget) |
I have a PR to add this ready but I'm a bit concerned about causing conflicts with AMS (I imagine that there are projects using both libraries simultaneously) WDYT about using: render jsonapi: model To avoid conflicts with |
That doesn't seem necessary, as I feel like it should use the model name to load the appropriate serializer and that serializer would define whether it's using AMS or fast_jsonapi via what it's inheriting from/what it includes. One thought - are you're saying that people have a model being serialized by both gems in different controllers/actions? |
@oniofchaos AMS right now is overriding ActionController::Renderers internal private methods making a bit hard your proposal. To use
I'm talking about people using AMS for some models and fast_jsonapi for other models, I think that is the case for some people looking to improving the performance in some serializers without having to migrate a whole existing project to fast_jsonapi. |
Just want to add a thumbs up to this.
Yes, it works, how about serializing an Array ? It would be great if fast_json could detect models inside an array and serialize properly & automagically. EDIT: Answering my question, if you pass an array it will serialize automatically. What got me was that you have to explicitly cast the AR relation to array.
|
I started a little project to help integrate To be honest, I'm not sure how much of the JSONAPI spec Consider this, as an example implementation: |
If I do something like
render json: model
, when I'm using AMS it automatically detectsModelSerializer
but when I'm switching over tofast_jsonapi
it doesn't seem to have that same magic. Am I messing something up or is that not a feature of this gem?P.S. Overall love the gem and the philosophy, thanks for open sourcing this.
The text was updated successfully, but these errors were encountered: