GithubHelp home page GithubHelp logo

Comments (9)

DavidBoyes avatar DavidBoyes commented on July 19, 2024

I've fixed this on my local copy by editing the method objectLoaderForObject method to check the request type and only include the paramaters if it is not a DELETE request:
if (method != RKRequestMethodDELETE) {
loader.params = params;
}

I believe that the object is supposed to be deleted from the core data store as well, but it appears this isn't happening.

Seems to be an error with this method
- (void)processLoadModelsInBackground:(RKResponse *)response

Seems flawed in how it works, it doesn't seem to reach the bit where it deletes the object as the logic checks for self.targetObject which is set by the objectLoaderForObject method.

Seems like it should be checking for self.method at some stage and then running deleteObject on the targetObject?

from restkit.

blakewatters avatar blakewatters commented on July 19, 2024

David -

I have not seen an instance where one would want to include parameters in the DELETE request, but its certainly possible. The right place to fix this for Rails is probably in the RKRailsRouter, where we can tie off the payload specifically for Rails idiomatic requests.

It does look like we should add support for deleting the object under the check for
if (self.targetObject) {
...
code path. The support at the bottom is for removing objects that don't appear in a loaded collection (i.e. I load an authoritative collection of objects and something in the cache is gone, it should be deleted). A check for method == DELETE and a successful response should trigger a delete of the persistent object.

from restkit.

DavidBoyes avatar DavidBoyes commented on July 19, 2024

Ok, I used the dynamic router as it did what I needed so haven't looked at the RKRailsRouter. I hacked on delete with something like this

if(_targetObjectID && self.method == RKRequestMethodDELETE) {
    NSManagedObject* backgroundThreadModel = [self.managedObjectStore objectWithID:_targetObjectID];
    [[objectStore managedObjectContext] deleteObject:backgroundThreadModel];
} 

Which worked but was mainly to test it out. I've had to swap to my own httpriot based model manager because I couldn't get certain things to work, but am keen to see RestKit progress so might contribute when I can as my own rolled one doesn't use coredata.

from restkit.

blakewatters avatar blakewatters commented on July 19, 2024

David -

We are adding support for the use-cases you outlined. What other issues have you been running into preventing adoption of RestKit? We are happy to fix/enhance the framework or offer support if it helps you use (and later contribute to :-) the library.

  • Blake

from restkit.

DavidBoyes avatar DavidBoyes commented on July 19, 2024

Posting with data was just flat out not working, my Rails dev server wasn't even acknowledging that it had been hit. It was pretty late at night so I sort of gave up without much debugging. I can swap to RestKit relatively easy so when I realise that adding my own local caching will be to much extra work I will probably swap back.

from restkit.

blakewatters avatar blakewatters commented on July 19, 2024

We have just pushed a fix that adds deletion of individual objects when a DELETE request is successful. We've also updated the Rails router so that it returns a nil serialization for DELETE requests against objects.

Swap it back when you have a change and we can see if things are working better.

Blake

from restkit.

DavidBoyes avatar DavidBoyes commented on July 19, 2024

I will swap it over and try it out.

from restkit.

blakewatters avatar blakewatters commented on July 19, 2024

Any update here?

from restkit.

DavidBoyes avatar DavidBoyes commented on July 19, 2024

Sorry, it appears to be fine now. Thanks

from restkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.