Am interested in the new PATCH method that will be included in Rails 4, but have a question/concern, and forgive me if I'm misunderstanding it.
So, if the request parameter _method is set to "patch", the update is processed as a patch. But, let's say you have a model called Airplane and Airplane has a collection of FlightCrewMembers which it accepts_nested_attributes_for. You get the Airplane resource via a RESTful call to Rails that contains the FlightCrewMembers list. Then something needs to make a PATCH to this resource and change both an attribute called autopilot_engaged on the Airplane while only changing the active_pilot flag of one of the FlightCrewMembers. You send this together to ensure that a single transaction is wrapped around both the update to autopilot_engaged on the Airplane and the active_pilot flag of one of the FlightCrewMembers. When you send the Airplane resource from the client to the RESTful service, you specify one or more FlightCrewMembers in the resource. If you truly wanted to patch, you should only have to specify the one FlightCrewMember in the Airplane's list of FlightCrewMembers and only specify the active_pilot flag on that FlightCrewMember. However, this could also indicate that the other 4 of the 5 FlightCrewMembers are no longer on the plane if the patch is also allowed to change which FlightCrewMembers are assocated with the Airplane. But that would mean you'd have to specify the list of ids of FlightCrewMembers in the patch request, which could have the unintended result of altering the list of members if one member had really left the plain at the same time (perhaps they are still on the ground and one just left the Airplane to run up the jetway). So, does there need to be new attributes on the Airplane resource that is passed in by the client to indicate whether the membership list of FlightCrewMembers is being altered on Airplane? And instead of just passing in a list of objects that only specify the id of the associated object to update the list, shouldn't the client (since they are providing a patch) be able to only specify which members are be deleted? Possibly support could be added for a new _remove key on the object to be removed from a list? That would seem to be a good name. That way you could either use the existing _destroy key that allows you to destroy the associated object or could use the new _remove key to just indicate that in your patch request you are specifying to remove it from the list. So, if the _method were "patch", then just specifying a list of objects only indicating their IDs wouldn't update the membership of that resource's collection. You would need to specify a _remove or _destroy key (depending on whether the client wanted to just remove it from the collection or actually destroy the object). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/PvCRFrUc5e8J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
