I'm working on exposing an API using RABL. Exposing the views is easy enough, but I've run into trouble having my own application consume those views.
For example, assume I have an endpoint at http://example.com/api/articles
, which produces a JSON representation of the articles.
In my ArticlesController#index
action, I wish to render a (HAML) view that shows a list of the articles. Rather than duplicate the logic from ArticlesApiController#index
, I want to simply use that data—i.e., I want to say "go get this data from the /articles
API endpoint," and then pass that data to the HAML view.
How can I do that? Or, is this the wrong way to go about doing this?