Hiding resource fields

Hi!

I've a Rails 2.0 site using RESTful resources. I added JSON support too, so the model can be get through HTML (using my views), XML and JSON (using .to_xml and .to_json)

The problem is that I want to hide some fields on the XML and JSON output (the HTML isn't a problem, because I control what I want to show on the view). For example, on the User model, I don't want to send the 'password' field via XML or JSON.

What's the best way to do this, and do it DRY around all RESTful methods? The only solution I was thinking is to write xml.builder and json.builder but there should be a easy way :slight_smile:

Greetings,
Ruben

Hi!

I've a Rails 2.0 site using RESTful resources. I added JSON support
too, so the model can be get through HTML (using my views), XML and
JSON (using .to_xml and .to_json)

to_xml/to_json take :except or :only options

Fred