-
Notifications
You must be signed in to change notification settings - Fork 186
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
access to assigned relationship #335
access to assigned relationship #335
Conversation
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.
nice catch! looks good
@@ -5,7 +5,12 @@ class Association < BaseAssociation | |||
def from_result_set(result_set) | |||
result_set.first | |||
end | |||
|
|||
def load_records(data) | |||
record_class = Utils.compute_type(klass, data["type"].classify) |
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.
After testing I have found there is a bug here, when the payload is in dash case running classify on the type
we get unexpected results. "skill-level". classify
will return Skill-level
. So what we need to do here is data["type"].underscore.classify
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.
If fixed this locally with
JsonApiClient::Associations::HasOne::Association.class_eval do
def load_records(data)
record_class = JsonApiClient::Utils.compute_type(klass, data["type"].underscore.classify)
record_class.load id: data["id"]
end
end
To access has_many results we have a further issue, without knowing the in's and outs I have overridden the method. I am guessing calling
|
fixes #334