active_model_serializers
https://github.com/rails-api/active_model_serializers
Ruby
ActiveModel::Serializer implementation and Rails hooks
ActiveModelSerializers::Adapter::JsonApi#links_for
{http://jsonapi.org/format/#document-links Document Links}
links
definition:
JSON Object
properties:
self : URI
related : link
description:
A resource object **MAY** contain references to other resource objects ("relationships").
Relationships may be to-one or to-many. Relationships can be specified by including a member
in a resource's links object.
A `self` member’s value is a URL for the relationship itself (a "relationship URL"). This
URL allows the client to directly manipulate the relationship. For example, it would allow
a client to remove an `author` from an `article` without deleting the people resource
itself.
structure:
{
self: 'http://example.com/etc',
related: link
}.reject! {|_,v| v.nil? }Edit
git clone [email protected]:rails-api/active_model_serializers.git
cd active_model_serializers
open lib/active_model_serializers/adapter/json_api.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActiveModelSerializers--Adapter--JsonApi-links_for-for-pr
# Commit to gitgit add lib/active_model_serializers/adapter/json_api.rbgit commit -m "better docs for ActiveModelSerializers::Adapter::JsonApi#links_for"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActiveModelSerializers--Adapter--JsonApi-links_for-for-pr
hub pull-request
# Celebrate!