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

add note about casing #1840

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ Features:
Fixes:

Misc:
- [#1840](https://github.com/rails-api/active_model_serializers/pull/1840) Add note about key_transform casing needing to match for multi-word fields. (@NullVoxPopuli)

### [v0.10.2 (2016-07-05)](https://github.com/rails-api/active_model_serializers/compare/v0.10.1...v0.10.2)

Expand Down
2 changes: 2 additions & 0 deletions docs/general/fields.md
Expand Up @@ -29,3 +29,5 @@ render json: @user, fields: { users: [:access_token] }
```

Where `users` is the JSONAPI type.

Casing for multi-word fields should match the casing specified for `ActiveModelSerializers.config.key_transform`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NullVoxPopuli Can you clarify with an example and explanation of how to thing about which casing to choose?

e.g.

# BAD, will not work because.... key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => [:attendee_name] }

# GOOD, will work because...key_transform is x, field name is y, adapter is z, serializer attribute is q, etc.
render json: search_result, fields: { 'event-attendance' => ['attendee-name'] }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I may need to add tests and / or reference my other PR that adds tests to refresh myself on what was happening