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

Grape::ActiveModelSerializers raises exception on missing serialization_context #1759

Closed
bf4 opened this issue May 31, 2016 · 0 comments
Closed

Comments

@bf4
Copy link
Member

bf4 commented May 31, 2016

Expected behavior vs actual behavior

Per #1268 (comment) and #1268 (comment)

The AMS Grape adapter does not pass in serialization_context, which is required to generate JsonApi pagination links, which raises an exception.

Environment

ActiveModelSerializers Version (commit ref if not on tag): 0.10.0

Output of ruby -e "puts RUBY_DESCRIPTION": 2.2.0

OS Type & Version: Mac, Yosemite

Integrated application and version (e.g., Rails, Grape, etc): Grape, but version unknown

Backtrace

(e.g., provide any applicable backtraces from your application)

"status":500
    "title":"Internal Server Error"
    "detail":"key not found: :serialization_context"
    "meta":{"error_class":"KeyError"
    "backtrace":
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api/pagination_links.rb:12:in `fetch'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api/pagination_links.rb:12:in `initialize'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api.rb:506:in `new'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api.rb:506:in `pagination_links_for'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api.rb:131:in `success_document'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/json_api.rb:48:in `serializable_hash'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/adapter/base.rb:29:in `as_json'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/serializable_resource.rb:8:in `to_json'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/serializable_resource.rb:8:in `to_json'"
    "~/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/active_model_serializers-0.10.0/lib/active_model_serializers/logging.rb:6
@bf4 bf4 changed the title ActiveModelSerializers::GrapeFormatter raises exception on missing serialization_context Grape::ActiveModelSerializers raises exception on missing serialization_context May 31, 2016
bf4 added a commit to bf4/active_model_serializers that referenced this issue May 31, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 added a commit to bf4/active_model_serializers that referenced this issue May 31, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 added a commit to bf4/active_model_serializers that referenced this issue May 31, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 added a commit to bf4/active_model_serializers that referenced this issue Jun 1, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 added a commit to bf4/active_model_serializers that referenced this issue Jun 1, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
onomated added a commit to onomated/active_model_serializers that referenced this issue Jun 1, 2016
- `serialization_context` is added in grape formatter so grape continues to continue work without explicit call `render` helper method
- Made it straightforward to add other serializer options (such as `serialization_scope`) by subclasses.
onomated added a commit to onomated/active_model_serializers that referenced this issue Jun 1, 2016
- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).
bf4 pushed a commit to bf4/active_model_serializers that referenced this issue Jun 9, 2016
* Fix rails-api#1759, Grape integration, adds serialization_context

- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).

* Updated Grape tests to include:
- paginated collections
- implicit Grape serializer (i.e. without explicit invocation of `render` helper method)

* Update Changelog with fixes.
bf4 added a commit to bf4/active_model_serializers that referenced this issue Jun 9, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 pushed a commit to bf4/active_model_serializers that referenced this issue Jun 9, 2016
* Fix rails-api#1759, Grape integration, adds serialization_context

- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).

* Updated Grape tests to include:
- paginated collections
- implicit Grape serializer (i.e. without explicit invocation of `render` helper method)

* Update Changelog with fixes.
bf4 added a commit to bf4/active_model_serializers that referenced this issue Jun 14, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
bf4 pushed a commit to bf4/active_model_serializers that referenced this issue Jun 14, 2016
* Fix rails-api#1759, Grape integration, adds serialization_context

- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).

* Updated Grape tests to include:
- paginated collections
- implicit Grape serializer (i.e. without explicit invocation of `render` helper method)

* Update Changelog with fixes.
onomated pushed a commit to onomated/active_model_serializers that referenced this issue Jun 14, 2016
- improves improves serialization_context to take options and not depend
on a `request` object.
- adds descriptive error on missing serialization_context.
- Document overriding `CollectionSerializer#paginated?`.
onomated added a commit to onomated/active_model_serializers that referenced this issue Jun 14, 2016
- `serialization_context` is added in grape formatter so grape continues to render models without an explicit call to the `render` helper method
- Made it straightforward for subclasses to add other serializer options (such as `serialization_scope`).
@bf4 bf4 closed this as completed in #1754 Jun 15, 2016
bf4 added a commit that referenced this issue Jun 15, 2016
…t_when_paginating

Fix #1759, Grape integration, adds serialization_context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant