如何防止 Ember 数据保存 ActiveModelSerializer 的只读属性
How to prevent Ember Data from saving a read-only attribute for ActiveModelSerializer
我正在尝试将 {readOnly: true}
功能与 ActiveModelSerializer
结合使用,方法是自定义序列化方法以忽略 RESTSerializer
的 for JSONAPISerializer
or this 等只读属性,以便在上传时过早保存带宽。
有谁知道 ActiveModelSerializer
是否可以做类似的事情?
ActiveModelSerializer
和 JSONAPISerializer
都扩展了 JSONSerializer
。 serializeAttribute
方法继承自JSONSerializer。所以我看不出有任何理由你不能采用你已经提到的 this Whosebug question 中给出的解决方案。
other answer on Whosebug relies on a very old API version of RESTSerializer
which has been removed before ember-data 1.x release. This has also been mentioned in another answer to same question.
我正在尝试将 {readOnly: true}
功能与 ActiveModelSerializer
结合使用,方法是自定义序列化方法以忽略 RESTSerializer
的 JSONAPISerializer
or this 等只读属性,以便在上传时过早保存带宽。
有谁知道 ActiveModelSerializer
是否可以做类似的事情?
ActiveModelSerializer
和 JSONAPISerializer
都扩展了 JSONSerializer
。 serializeAttribute
方法继承自JSONSerializer。所以我看不出有任何理由你不能采用你已经提到的 this Whosebug question 中给出的解决方案。
other answer on Whosebug relies on a very old API version of RESTSerializer
which has been removed before ember-data 1.x release. This has also been mentioned in another answer to same question.