-
Notifications
You must be signed in to change notification settings - Fork 1.4k
make serialization_context available in link #1976
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
Conversation
@_routes ||= nil # handles warning | ||
# actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:417: warning: instance variable @_routes not initialized | ||
@object = serializer.object | ||
@scope = serializer.scope | ||
@context = adapter_options[:serialization_context] |
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.
any reason you can't use the scope?
@@ -467,7 +467,7 @@ def relationships_for(serializer, requested_associations, include_slice) | |||
# }.reject! {|_,v| v.nil? } | |||
def links_for(serializer) | |||
serializer._links.each_with_object({}) do |(name, value), hash| | |||
result = Link.new(serializer, value).as_json | |||
result = Link.new(serializer, value, instance_options).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.
should probably mirror usage in pagination links?
- https://github.com/f-mer/active_model_serializers/blob/a6a8f53cadc1205b19f0ead41ab5c3f2d03bed10/lib/active_model_serializers/adapter/json_api/pagination_links.rb
- https://github.com/f-mer/active_model_serializers/blob/a6a8f53cadc1205b19f0ead41ab5c3f2d03bed10/lib/active_model_serializers/adapter/json_api.rb#L507
Thanks for getting back at this! Yep that was the idea. render json: @resources, scope: view_context, scope_name: :view_context Links could be build like this: link :self do
view_context.api_resource_url(object)
end and the |
Closing this pull request because |
Purpose
Makes it possible to build urls of engines with isolated namespace by passing the
ActionDispatch::Routing::RoutesProxy
(my_engine
).Changes
Pass serialization_context to link.