tapajos/highrise — Issue #32: 422 Unprocessable Entity on update due to nested models
Author: reidab
Created: 2012-01-31 10:11:23+00:00
State: open

When updating a Deal, if a nested Party model is included in the post body, a 422 error is being returned.

According to [this message](https://groups.google.com/group/37signals-api/browse_thread/thread/1630ef4eb22231e8), Highrise has recently started returning 422 errors in cases where it hadn't before.

Testing manually, I found this to work fine

```xml

Deal

```
While this 422'd

```xml

Deal

```

I got around it for my immediate needs by monkey-patching the Deal class as follows, but there's surely a more elegant solution to be had.

```ruby
module Highrise
class Deal
def encode_with_nested_attribute_exclusion(options={})
encode_without_nested_attribute_exclusion({:except => [:party, :parties]}.merge(options))
end
alias_method_chain :encode, :nested_attribute_exclusion
end
end
```