-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
How to get to_json to behave without render? #1487
Comments
You can't, as it is mentioned in this document Basic Serializer in design docs.
So it won't use your serializers |
@dudo What version of AMS are you on? https://github.com/rails-api/active_model_serializers/blob/master/CONTRIBUTING.md The docs describe how to serialize outside a controller https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/outside_controller_use.md @domitian the file you linked is the original design doc from 2011 |
0.10.0.rc4
Hopefully that describes the mismatch. I'm using Devise, not sure if that messes with serialization. Also, |
Yeah, that's not the way to do it. The json gem adds methods all ruby objects. I am thinking of moving making the serializer behave like the attributes adapter when calling as_json on it. In any case, see #1487 (comment) where I ref'd what you need to do |
To be clear, that's the instruction from /outside_controller_use.md, yes? AHHHHHH. I was looking at it the whole time. It says |
no prob. Glad it's figured out. |
In my controller, I can convince the app to use my serializers:
But for the life of me, I can't seem to figure out how to get the object to use the serializer on command. I've tried the following to no avail:
What am I missing?? This is driving me nuts.
The text was updated successfully, but these errors were encountered: