Excluding fields from rails json and xml output

Rails has a very handy ‘respond_to’ feature to render your pages in different formats : respond_to do |format| format.json { render :json => @user } format.xml { render :xml => @user } format.html end However, by default it outputs every field in the model, which exposes some data (encrypted-password and password-salt) that I’d rather keep to myself : ...

October 3, 2010 · 1 min · Dave Perrett

Format JSON with PHP

...

March 11, 2008 · 2 min · Dave Perrett