Hey guys, I'm glad that this has gotten a robust discussion going. I'm not 
sure I fully explained what I actually need to be done.

I'm using the jQuery datatables plugin, and for server-side filtering, it 
requires some extra data in the JSON extract that doesn't come from a 
.to_json call on a Sequel data object.

For example, dataTables expects a structure like the following:

{
 "draw": 1,
 "recordsTotal": 57,
 "recordsFiltered": 57,
 "data": [
   [
     "Airi",
     "Satou",
     "Accountant",
     "Tokyo",
     "28th Nov 08",
     "$162,700"
   ],
   [
     "Angelica",
     "Ramos",
     "Chief Executive Officer (CEO)",
     "London",
     "9th Oct 09",
     "$1,200,000"
   ]
 ]
}

In this case, the "data" attribute is the set of objects returned by 
Sequel, but the other attributes need to be manually created or set. Is 
there a way for me to return JSON like this while using .to_json?

I've tried something like the following:
@data = Model.where(:attribute => true) #Filtered based on POST data from 
datatables

{:recordsTotal => Model.all.count, :recordsFiltered => @data.count, :data => 
@data.to_json}.to_json

But that resulted in double escaped JSON that didn't parse.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to