Skip to content

Instantly share code, notes, and snippets.

What would you like to do?


We need changes in the API and Admin endpoint in order to serve content to CME clients. This content will be produced by an external app and stored on S3. A new endpoint is needed for this external app to notify when content has changed.

Suggested changes

Data model

  1. Add two new fields Course model:
  • cme_article_url (string)
  • cme_qa_url (string)

These will point to JSON files hosted on S3.


Source file: app/api/cme_api_v1.rb

1) Update endpoint GET courses/:course_name

Update endpoint GET courses/:course_name to serve new fields:

  • cme_article (JSON)
  • cme_qa (JSON)

These fields should contain the actual JSON content located at cme_article_url and cme_qa_url URLs.

2) Fetch JSON content

The JSON content should be fetched from S3 (two requests) when handling the API request, using standard Rails caching, with a duration of 1 hour.

3) New endpoint POST courses/:course_name/update_content

Add new endpoint POST courses/:course_name/update_content. Call to this endpoint forces the cache mentioned in 2) to be refreshed.

This endpoint will be called from an external source, so it should require an api_key param which should match Rails.application.secrets.cme_external_api_key (to be put in secrets.yml).

(See authenticated_by_api_key in app/api/api_helpers.rb and app/api/api_v4.rb for example on how we use api_key).


  1. Show new editable fields cme_article_url and cme_qa_url in Course edit form.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment