well...it's working but it's not pretty:
<code>
def getnew
  if request.xhr? and id=request[:id]
    tasks = Task.filter('id < ?', id)
    json = mda(tasks.count, 3)
    i=0
    Task.filter('id < ?', id).each do|task|
      #create json object
      json[i][0]= "{ \"id\" : \"#{task[:id]}\","
      json[i][1]= "\"created_at\" : \"#{task[:created_at]}\","
      json[i][2]= "\"task\" : \"#{task[:task]}\"}"

      #prepend opening bracket if it's the first one
      if(i==0)
        json[0][0] = "[#{json[0][0]}"
      end

      #append closing bracket or comma if it's not the last one
      if(i==tasks.count-1)
        json[i][3] = "#{json[i][3]}]"
      else
        json [i][3] = "#{json[i][3]},"
      end

    i=i+1
    end

    json
  end
end

def mda(width, height)
  Array.new(width).map!{ Array.new(height) }
end


</code>

There must be an easier way right?

Things I need to learn how to do:
1. create loops without creating and incrementing 'i' by myself
2. learn the syntax for short if statements
-- 
Posted via http://www.ruby-forum.com/.