When I use RestfulController in Grails to save data for an object, how can I prevent the client from applying changes to a related child object?
Given the following domain classes:
class Language {
String name
}
class TranslationText {
Language language
String text
}
And the following POST data for a TranslationText:
{
"language": { "id": 1, "name": "InvalidName" },
"text": "Some Text"
}
Here, I want to reference an existing Language resource (with ID=1), but I don't want the name to be altered by the client.
How can I save this resource with the text and language (based on ID), but discard the invalid language name property?
I want to modify RestfulController in the most minimal way possible, preserving default behavior as much as I can.