Skip to content

Instantly share code, notes, and snippets.

View beechnut's full-sized avatar

Matt Cloyd beechnut

  • 18F (work) + personal projects
  • Philadelphia, PA
View GitHub Profile
@beechnut
beechnut / hypermedia-review.md
Last active January 2, 2016 23:59
A "blow-by-blow" of my hypermedia-in-Rails work on beechnut/mfapi

I started with simple, concrete hypermedia for Objectives. For the collection I created a collection method, into which I passed the Objectives to create a collection+json object. For a single record, I loop through its associations with reflect_on_all_associations, and create links to all its associated objects.

I then moved this logic to ApplicationController and abstracted it for use with Indicators.

Namespaces in this hackery were a little tricky: self_link could theoretically mean either:

{"rel": "self", "href": "/path/to/self"}