ruby on rails - include_root_in_json from controller -


i'm trying return result view json not include root.

i don't want set on actions model,so therefore trying avoid setting

 activerecord.base.include_root_in_json = false 

i hoping

 @task = tasks.all @task.include_root_in_json = false 

to response need, doesn't seem working, returning 'undefined method include_root_in_json= #

is there nice way of doing this??

it's old question now, answers not updated, , rails 3.2 filled gap (rails source)

with rails 3.2, can use:

my_model.to_json(:root => false)

if don't want root key included.

it gets better tested array, can do:

model.all.to_json(:root => true)


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -