-
Notifications
You must be signed in to change notification settings - Fork 529
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
undefined method serialize_to_hash ... what's happend #1149
Comments
@ohimy we can't help you if you don't provide more details |
In the documentation under serializer it has Try it. You now get this error on master branch:
It looks like this commit (bdcbf61) completely removes the method from the ResourceSerializer? It also comments out / removes all the unit tests associated with the method. It's not clear what new method (if any) replaces the old one either... More than 5000+ lines of changes with no unit tests and comments that say: I would not consider master stable after seeing this :) Any update to how this is supposed to work @lgebhardt ? |
Today i have this is error on version 0.10.0 |
Yep, just ran into this when trying to upgrade. The docs and the code definitely don't seem to agree. |
I switched away from JSONAPI::Resources because I felt like I would need custom actions and I couldn’t figure out how to serialize manually à la serialize_to_hash: cerebris/jsonapi-resources#1149
Thank you for creating jsonapi-resources. Can you give us any guidance on how to upgrade, if we are dependent on the old It seems, we can still accomplish something similar by using It's quite a nice thing to be able to use jsonapi-resources to serialize to JSON since, sometimes I want to be able to do things with my objects' JSON on the server, apart from the API. Since This is how I used to do it:
This would then allow me to do stuff like this, to get the actual JSON:
Thanks! |
Any suggestions here? Again docs don't line up and my google-fu is failing me. 😞 |
Ok I think figured it out from the test cases: https://github.com/cerebris/jsonapi-resources/blob/master/test/unit/serializer/serializer_test.rb#L23-L37 Please forgive my ignorance but this seems way more complicated than the previous version's implementation. Am I missing something here? Feels like slicing up watermelon till we get water... |
Is this issue completely abandoned? |
I am impacted by this as well. I switched to version |
This issue is causing our project tons of problems. We had a bunch of code that followed the pattern described in the docs, which no longer works. Ideally the code from the docs should continue to work, and show a deprecation message if necessary with instructions on how to migrate. |
I think the docs might just need updating for v0.10+. There's an
Specifically, when rendering a resource in a non- def show
post = Post.find(params[:id])
# ... business logic ...
resource = PostResource.new(post, { :current_user => current_user })
json = JSONAPI::ResourceSerializer.new(PostResource).object_hash(post, { :comments => post.approved_comments })
render :json => { :data => json }
end NOTE: The above isn't setting the |
Bumped into this issue today trying to upgrade from 0.9.6. Any updates here? |
I'm having the same issue. |
@lgebhardt can you provide any insight on this? |
@jamesdixon et al: I asked on the Gitter channel, here's his reply. Thank you @lgebhardt for maintaining this library, and please ping me if I can help test things for this use-case in v0.11! |
@tobias-grasse thank you! |
hoisting the answer from gitter here for convenience Larry Gebhardt @lgebhardt Oct 27 11:06 Yes, v0.10 has made just serializing a resource a difficult task. I just wasn't aware of how many people were using the library that way. Restoring this functionality for v0.11 is a priority speaking for myself, we had a test that was like context = { current_user: user }
resource_class = V1::JobResource
resource_options = {
include: ["job_template",],
meta: { "job" => "current_user_can_actions" },
}
serializer = JSONAPI::ResourceSerializer.new(resource_class, resource_options)
resource_instance = resource_class.new(model, context)
as_json = serializer.serialize_to_hash(resource_instance) |
Temporary can use this
|
@Lifehack043 this is working for me so far on v0.10.5 |
On 0.10.5, I tried using @bf4's solution but had to make a small change to finally get it working -
This is all without additional metadata/context being passed. See the prior comment for details on that |
Master has unrelated code which adds serialize_to_hash #1348 |
For me the comment by @xicreative worked perfectly fine on 0.10.7. I just replaced |
as @bf4 mentioned, it looks like the solution is in place and we just need it shipped. how can we get the next gem version published? |
@lgebhardt @dgeb @HeatherGebhardt @senid231 can this fix be applied to the 0.10.x branch? |
we're also being affected by this - hoping as mentioned above the fix can be applied to the 0.10.x branch |
same here, it'd be helpful to have a 0.10.x release with the fix in place |
Hi, is there any update on this? Currently, using 0.10.7 |
This issue is a (choose one):
Checklist before submitting:
Description
Choose one section below and delete the other:
Bug reports:
Please review Did you find a bug? and replace this content with a brief summary of your issue. If you can't submit a bug report template please be as thorough as possible when describing your your description. It's helpful to indicate which version of ruby and the JR gem you are using.
Features:
Please replace this line with a clear writeup of your feature request. Features that break compliance with the JSON:API spec will probably be closed.
The text was updated successfully, but these errors were encountered: