https://github.com/ericlondon/rails5-api-family-tree-associations
Rail 5 API Family Tree Associations
https://github.com/ericlondon/rails5-api-family-tree-associations
api associations rails5
Last synced: 8 months ago
JSON representation
Rail 5 API Family Tree Associations
- Host: GitHub
- URL: https://github.com/ericlondon/rails5-api-family-tree-associations
- Owner: EricLondon
- Created: 2018-11-25T15:28:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-23T12:07:12.000Z (about 1 year ago)
- Last Synced: 2025-01-12T01:24:02.397Z (9 months ago)
- Topics: api, associations, rails5
- Language: Ruby
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rail 5 API Family Tree Associations
```
# setup
rake db:create && rake db:migrate
rake people:create# create people
rake people:create# run server (puma)
rails s# curl request
curl -XGET 'http://localhost:3000/api/people' | jq '.[0]'
{
"id": 1,
"first_name": "Eric",
"last_name": "London",
"maiden_name": null,
"gender": "male",
"depth": 0,
"spouse_id": 2,
"mother_id": 3,
"father_id": 4,
"children_ids": [
5,
6,
7
],
"sibling_ids": [
8,
9
]
}# run RSpec tests
rspec
35 examples, 0 failures
```Disclaimer: Sorry, relationships are binary and simplified in this example code.
TODO:
- [ ] resolve N+1 issues when fetching siblings and children associations