Hi,

I'm trying to do an AJAX request from my xhtml page to a controller.
The AJAX request passes "id=idgoeshere" where idgoeshere is a number.
Inspecting in Chrome inspector shows me that the id is being passed so
no problems there.

The problem I have is when I try to get my controller to return some
data.  I'm using Sequel as my DB and my controller runs a query and is
then supposed to output a json formatted object but I can't get it to
work.

I've tried a few things already:

1.
<code>
Task.filter('id < ?', id).each do |task|
        "{\"task\" : \"#{task.task}\",\"createdat\" :
\"#{task.created_at}\", \"id\" : \"#{task.id}\" }"
end
</code>
Generates: #<Sequel::SQLite::Dataset:0x4253fc4>
2.
<code>
Task.filter('id < ?', id).each { |task|
        "{\"task\" : \"#{task.task}\",\"createdat\" :
\"#{task.created_at}\", \"id\" : \"#{task.id}\" }"
        }
</code>
Generates: #<Sequel::SQLite::Dataset:0x4253fc4>
I installd the JSON gem and have tried the next two:
3.
<code>
json = JSON.generate(Task.filter('id < ?', id))
json
</code>
Generates error: JSON::GeneratorError: only generation of JSON objects
or arrays allowed
4.
<code>
json = JSON.generate(Task.filter('id < ?', id).to_a)
json
</code>
Generates: ["#<Task:0x42527c8>","#<Task:0x4251814>".....etc]

What I'm trying to return to my xhtml is a JSON object containing all of
my tasks that are returned from the DB, does anyone have any pointers on
how to do it?

Thanks in advance!

Btw, I'm using Ramaze framework but I don't think this is a Ramaze
framework issue so I'm posting it here...
-- 
Posted via http://www.ruby-forum.com/.