Skip to content
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

map :base attribute to '/data' source pointer if not used as an attribute #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gmkohler
Copy link

@gmkohler gmkohler commented Mar 29, 2019

The specification for "/data" in a JSONAPI error object's source attribute and the suggested usage of :base in ActiveModel::Error seem aligned.

Wrote this such that any actual :base attribute would override this, but not sure what sort of tests need to be added or whether it's worth adding at all.

@gmkohler gmkohler changed the title map :base attribute to '/data' if not used as an attribute map :base attribute to '/data' source pointer if not used as an attribute Mar 29, 2019
@JoeWoodward
Copy link

Might make sense to make this customizable too. I use form objects and attach exceptions to an attr_accessor :exception which should also be attached to /data if this interpretation of the spec is correct.

The only thing I think might be wrong here is that nested association errors shouldn't be on base but rather on a relationship instead. However, that's not in v1 of the spec so not sure

@gmkohler
Copy link
Author

@JoeWoodward can you write an example of what you mean by:

The only thing I think might be wrong here is that nested association errors shouldn't be on base but rather on a relationship instead

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants