<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - RailsCast#340 - JSON not well formed for dataTables]]></title>
		<link>http://railsforum.com/viewtopic.php?id=53722</link>
		<description><![CDATA[The most recent posts in RailsCast#340 - JSON not well formed for dataTables.]]></description>
		<lastBuildDate>Mon, 04 Mar 2013 09:06:31 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: RailsCast#340 - JSON not well formed for dataTables]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160841#p160841</link>
			<description><![CDATA[<p>Hi musicman,<br />thanks for answering... </p><p>I solved the &#039;JSON&#039; format problem, it was not due to my js but to the way I did my objects mapping ... I made my original mapping following the RailsCast, but it is made for an older version of dataTables, now I map my objects with</p><div class="codebox"><pre><code>users.map(&amp;:attributes)</code></pre></div><p> and the JSON is conform to the one expected by dataTables</p><p>Now the problem I&#039;m facing is due to the fact I use CoffeeScript and have a serious lack of knowledge with it, for example I cannot initialize &#039;aoColums&#039; correctly, (the columns are read as only one block...)-- You can follow the discussion wuth Allan on <a href="http://%20http://datatables.net/forums/discussion/14407/problem-with-json-format-help-and-explanations-needed"> http://datatables.net/forums/discussio &#133; ons-needed</a><br />I guess I will try to use only &#039;pure jQuery, let the CoffeeScript part for later...</p><p>The next challenge that I could hit is to have it to work with joined tables... I had it working with the &#039;bad&#039; JSON, hope it will work the same with the good one...</p><p>Cheers</p>]]></description>
			<author><![CDATA[dummy@example.com (anso)]]></author>
			<pubDate>Mon, 04 Mar 2013 09:06:31 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160841#p160841</guid>
		</item>
		<item>
			<title><![CDATA[Re: RailsCast#340 - JSON not well formed for dataTables]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160834#p160834</link>
			<description><![CDATA[<p>Can you post the JS where you are initializing Datatables?</p>]]></description>
			<author><![CDATA[dummy@example.com (themusicman)]]></author>
			<pubDate>Mon, 04 Mar 2013 06:13:47 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160834#p160834</guid>
		</item>
		<item>
			<title><![CDATA[RailsCast#340 - JSON not well formed for dataTables]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160804#p160804</link>
			<description><![CDATA[<p>In the RailsCast#340 Datatables, it appears that the JSON array returned is not what is expected by DataTables.</p><p>Let say for a model User where mapping returns user.id, user.last_name, user.first_name, user.email the returned JSON is<br /></p><div class="codebox"><pre><code>aaData: [[1, DOE, John, doe@example.com,…],[7, BAXTER, Bill, baxter@example.com],[15, BROWN, Bob, brown@example.com],...]</code></pre></div><p>wich is a one dimension array, and the 2 dimensions arraay expected by DataTables (for the aaData part) should be for the same set of data</p><div class="codebox"><pre><code>aaData: [{&quot;id&quot;:1, &quot;last_name&quot;:&quot;DOE&quot;, &quot;first_name&quot;:&quot;John&quot;, &quot;email&quot;:&quot;doe@example.com&quot;,…},{&quot;id&quot;:7, &quot;last_name&quot;:&quot;BAXTER&quot;, &quot;first_name&quot;:&quot;Bill&quot;, &quot;email&quot;:&quot;baxter@example.com&quot;],{&quot;id&quot;:15, &quot;last_name&quot;:&quot;BROWN&quot;, &quot;first_name&quot;:&quot;Bob&quot;, &quot;email&quot;:&quot;brown@example.com&quot;},...]</code></pre></div><p>So if it displays well in the example provided it throws error when filtering server-side with an error</p><p>&quot;JSON data from server could not be parsed. This is caused by a JSON formatting error&quot;</p><p>Is there anybody who knows how to return the well formatted JSON ?</p><p>Any help would be appreciate</p>]]></description>
			<author><![CDATA[dummy@example.com (anso)]]></author>
			<pubDate>Sat, 02 Mar 2013 18:55:29 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160804#p160804</guid>
		</item>
	</channel>
</rss>
