-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Serializer trying to look for attribute where it does not exist [0.10.0] #911
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
Comments
Any idea on how to work around this nicely? I added the methods that it was throwing error about into my Comment model. Now it will pass without errors. But my Comment should not contain thoes attributes at all what it is trying to put into it. |
This is indeed bug due to these two lines here and here. In the first line, the Workaround -> Specify your association serializer, e.g.: class MediumSerializer < ActiveModel::Serializer
has_many :comments, serializer: CommentSerializer
end Fix -> change this line to: serializer_class.new(object, options.except(:serializer)) |
Thank you for the response! I hope this will get fixed soon. Will go with the workaround for now. |
Avoiding the serializer option when instantiating a new one for ArraySerializer Fixed #911
So I have this media serializer:
And the
has_many :comments
looks for this serializer:Now in my controller I am querying for media, so I get an array of mediums.
And now when I load the page that uses this serializer, I get this error:
The error only occurs when I have an array of mediums. When I just query a single medium and use the same serializer, then the error is not there.
The image_video_file_name and the rest of similar attributes all exist in the database and are useable inside of ruby code. Also when I query a single medium, I can see all of these attributes.
What exactly is wrong here? It used to work with 0.9.x but I am using 0.10.0 now and for some reason it just does not want to work now.
The text was updated successfully, but these errors were encountered: