I\'m trying to return a result to a view where the json does not include the root.
I don\'t want to set this on all actions for this model,so therefore am trying to
It's an old question now, but the answers were not updated, and Rails 3.2 filled the gap (Rails source)
With Rails 3.2, you can now use:
my_model.to_json(:root => false)
if you don't want the root key to be included.
It gets even better as I just tested it with an array, so you can do:
Model.all.to_json(:root => true)