0

I have a hash H which should contain various users as json. "users" list contains all users and every user object contains various user's details like name, age etc. I don't want to iterate over every user in the list and do user.as_json and then merge into the hash.

Is there a single line query which does this?

user99785
  • 9
  • 3

1 Answers1

0

You can do this, in your action convert it to JSON by using to_json

@users = users.to_json

In the Javascript code, parse it using jQuery's $.parseJSON()

$.parseJSON(@users)
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78