I'm trying to include in my page, a json object which will act as a javascript object.
I've got it pretty simply in my controller
def index
@tasks = User.select("task_id,desc")
end
in my view, I thought I'd be able to put
var tasks = <%= @tasks.as_json %>
but that outputs
[#<Task task_id: 1, shrtDesc: "task 1">, #<Task task_id: 2, shrtDesc: "task 2">]
what I was expecting was
{"task_id":1, "shrtDesc": "task 1"}, {"task_id":2,"shrtDesc":"task 2"}