Skip to content

Instantly share code, notes, and snippets.

@pedro
Created June 30, 2010 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedro/458283 to your computer and use it in GitHub Desktop.
Save pedro/458283 to your computer and use it in GitHub Desktop.
A few people asked about my issue with Rails 3 so here's the summary:
* Overriding to_json doesn't work anymore - render :json => User.all
seems to be ignoring any options defined in there.
* So I google around, there's a great explanation behind that, cool.
Lets move on and define as_json...
* Only it doesn't work if you try to call super with :only, :except,
or any of those options. Rails kept rendering all attributes.
* Things got worse when I added "json" to my Gemfile so I could test
that API giving me trouble. to_json starts raising "wrong number of
arguments" out of nowhere.
* Couldn't find any official doc for as_json.
* Ended up fixing my issue by reading the code. It's my fault I made
the wrong assumption about as_json, although I still don't see why
does it take arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment