Support relation by foreign id #62

wants to merge 7 commits into


None yet
2 participants

xslim commented Oct 8, 2012

Currently relations are supported by searching relationName in representation

This hack allows building relations by using relationName_id or relationName_ids, as many Ruby on Rails engines return.


mattt commented Oct 11, 2012

Thanks for your pull request, @xslim. There's a lot in here other than the foreign ID stuff, so it's going to take some time for me to determine what I should take from this. Bear with me for a moment.

xslim commented Oct 11, 2012

Sorry for a lot of commits, I'm trying to use the library in current app development, and I stuccoed with the problem of entities are not saved in DB. So some of the commits are fixing this issue.

xslim commented Oct 11, 2012

Also I've made implementation for sending If-Modified-Since and working with 304 Not Modified… but this work is currently in my gist

If you have any comments how to improve the code for pull request - please tell me I'll do that.


mattt commented Oct 11, 2012

No worries at all—thanks for your contributions.

As it were, I just added Last-Modified support myself, with 40bee2d. It takes a different approach from yours by managing Last-Modified in the same way as resource identifiers. Interested to hear any thoughts you have.

xslim commented Oct 11, 2012

You developed Last-Modified for "per-resource request"

What I did in my gist, is developed Last-modified when requesting "array" of items.

The example implementation on rails side is

  def index
    @areas = parent.areas
    if stale?(last_modified: @areas.max(:updated_at))
      respond_with @areas

So I get the last modified area in database, and send this info to server. Server checks it against his DB and returns just :304 if nothing changed, or :200 with the list of areas if there were changes. This saves bandwidth.

xslim commented Oct 11, 2012 prevents crashing when server sends 304 Not-Modified and empty data in success.

To make 304 a success response I also added this code in APIClient subclass

// 304 Not-Modified
[AFJSONRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:304]];

xslim commented Oct 12, 2012

Should I change my pull request to reflect your latest commits?


mattt commented Nov 18, 2014

As of e8c6472, AFIncrementalStore is no longer being actively maintained. Thank you for your contributions; my sincere apologies for any inconvenience this may have caused.

@mattt mattt closed this Nov 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment