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 avoid setting
ActiveRecord.Base.include_root_in_json = false
I was hoping that I could do
@task = Tasks.all
@task.include_root_in_json = false
To get the response I need, but that doesn't seem to be working, returning an 'undefined method include_root_in_json= for #
Is there a nice way of doing this??
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…