Feature: support manually specified sideload data in ActiveModel::Serializers

85 views
Skip to first unread message

Doug Puchalski

unread,
Jun 1, 2014, 11:49:06 AM6/1/14
to rails-a...@googlegroups.com
I have a need to sideload resources that are indirectly associated with the resources being loaded.

{
  transactions: [
    {
      name: 'Deposit',
      date: '01/01/2014',
      amount: '123.45'
    }
  ],
  balances: [
    {
      date: '01/01/2014',
      amount: '123.45'
    }
  ],
  meta: {
    // ...
  }
}

The balances here are not directly linked to the primary resource being loaded, the transactions. But I'm always going to want them included. I'm not sure making a separate API is the solution, when the two calls will always be made in succession.

I have implemented a manual sideband feature where I can specify another hash to be added alongside the root, similar to `meta`'. 

Would this be welcome as a PR?

Adrian Mugnolo

unread,
Jun 2, 2014, 11:47:08 AM6/2/14
to rails-a...@googlegroups.com
Hi Doug,

This could or could not be a valid PR for AMS, depending on whether we go with JSON API or standardized conformance or custom formats support. Please see the ongoing discussion: https://groups.google.com/forum/?fromgroups=#!topic/rails-api-core/pGSWLiWUsCw. Particularly, I'm not sure how indirectly related resources are treated in JSON API and other standard formats.

Regards
Reply all
Reply to author
Forward
0 new messages