-
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
Fix namespace lookup for collections and has_many #1973
Fix namespace lookup for collections and has_many #1973
Conversation
@groyoh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @NullVoxPopuli and @bf4 to be potential reviewers. |
@NullVoxPopuli FYI |
expected = { | ||
'title' => 'New Post', | ||
'body' => 'Body', 'writer' => nil, | ||
"chapters"=>[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some formatting here. Did you run rubocop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turned out I ran it without git add
'ing it :)
Just the formatting issue, and changelog entry needed. :-) then we can merge |
Sure thing! |
f7db7e2
to
47d1931
Compare
47d1931
to
7bfacf8
Compare
|
||
class ChapterSerializer < ActiveModel::Serializer | ||
attribute :title do | ||
"Chapter - #{object.title}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When AMS doesn't find the serializer it uses resource.as_json
. So I added this "Chapter -"
part, to make sure that we use the namespaced serializer instead of resource.as_json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that -- good thinkin'
@NullVoxPopuli fixed formatting and added CHANGELOG. |
Purpose
Due to the
CollectionSerializer
not passing thenamespace
option to the lookup, the namespace lookup doesn't work for collections and has_many relationships. This PR fixes it.Changes
Pass the
namespace
option to the serializer lookup from theCollectionSerializer
.Related GitHub issues
#1757 (comment)