Super simple setup:
- Created a new rails app with
--api
and added the generator/framework - Created a single model (Artefacts) with a
name
attribute and ahas_many
relationship to other Artefacts (boringly named.artefacts
) - Created 2 nodes, and joined them (
node1.artefacts = node2
)
Now, when browsing to /artefacts
, the JSON returned is just the 2 nodes.
How can Rails return the relationships
and for down the road; how can Rails return a custom JSON layout such as:
[{"artefact":{"name":"Node1","id":"e6571172-889c-4dd9-abca-a522f28c970d", artefacts: ["0643d8c5-fc67-431c-b015-7c5894439058", "5e7ceb40-18da-474e-8fe0-22d3887943b4"]}}]