开发者

How to exclude specific fields from a Rails XML output

开发者 https://www.devze.com 2022-12-17 05:07 出处:网络
I am working on a RoR project which outputs XML to RESTful requests.The problem is it includes the \"updated-at\" and \"created-at\" fields in the output.

I am working on a RoR project which outputs XML to RESTful requests. The problem is it includes the "updated-at" and "created-at" fields in the output.

I have tried using:

:exclude -> [ :created_at, :updated_at ] 

and

:exclude -> [ 'created-at', 'updated-at' ]

but the output still renders them. How do I exclude them from the rendering w开发者_如何学JAVAithout these?


The option you want is called :except, not :exclude. For example:

obj.to_xml(:except => [ :created_at, :updated_at ])

For more info, see the Rails API docs for this method.

0

精彩评论

暂无评论...
验证码 换一张
取 消