<?xml version="1.0" encoding="utf-8"?>

			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>TheRealTimeWeb.com - Rails</title>
			<link>http://www.therealtimeweb.com/index.cfm</link>
			<description>A technology blog with a special focus on real-time web technologies, web video and the Flash Platform.</description>
			<language>en-us</language>
			<pubDate>Sun, 19 May 2013 11:14:28 +0100</pubDate>
			<lastBuildDate>Fri, 15 Mar 2013 06:36:00 +0100</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>stefan@therealtimeweb.com</managingEditor>
			<webMaster>stefan@therealtimeweb.com</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>stefan@therealtimeweb.com</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			
			<itunes:explicit>no</itunes:explicit>
			
			<item>
				<title>Loading JSON From Rails with jQuery, Avoiding 406 Error</title>
				<link>http://www.therealtimeweb.com/index.cfm/2013/3/15/rails-jquery-406</link>
				<description>
				
				First of all I should point out that I&apos;m quite new to Rails (and jQuery) and the interactions between it and JQuery, which may be the reason that some of you may consider this a rather basic hint.&lt;br&gt;
However whilst working on &lt;a href=&quot;http://www.membermeister.com&quot; target=&quot;_blank&quot;&gt;membermeister.com&lt;/a&gt; I&apos;ve recently had some trouble loading JSON data from our Rails backend. It seemed like a very trivial task at first, all we needed was a GET request that was answered by a format.json response from the Rails controller.&lt;p&gt;
Simplified the request looked something like this:
&lt;p&gt;
&lt;code&gt;
$.ajax({
	url: &quot;/invoices/&quot; + invoiceid + &quot;/pay&quot;,
	type: &quot;GET&quot;
})
&lt;/code&gt;
&lt;p&gt;
However Rails was returning a &apos;406 Not Acceptable&apos; error, suggesting the request I was sending was not something it was instructed to handle.In my noobness I tried passing
&lt;p&gt;
&lt;code&gt;
dataType: &quot;json&quot;,
&lt;/code&gt;
&lt;p&gt;
I also tried 
&lt;code&gt;
contentType: &quot;json&quot;
&lt;/code&gt;
&lt;p&gt;
but always got this error:
&lt;img src=&quot;http://www.therealtimeweb.com/images/membermeister005.jpg&quot; /&gt;
&lt;p&gt;
In the end the fix was quite simple but had evaded me for a while: 
&lt;code&gt;
beforeSend: setHeader&lt;/code&gt;
&lt;p&gt;
followed by 
&lt;p&gt;&lt;code&gt;
function setHeader(xhr) {
	xhr.setRequestHeader(&quot;Accept&quot;, &quot;application/json&quot;);
}
&lt;/code&gt;
&lt;p&gt;
The complete function looked (simplified) like this:
&lt;p&gt;
&lt;code&gt;
$.ajax({
	url: &quot;/invoices/&quot; + invoiceid + &quot;/pay&quot;,
	type: &quot;GET&quot;,
	beforeSend: setHeader
}).done(function() {
...			
});

function setHeader(xhr) {
	xhr.setRequestHeader(&quot;Accept&quot;, &quot;application/json&quot;);
}
&lt;/code&gt;
&lt;p&gt;
Once implemented the GET request succeeded (notice the Accept Request Header).
&lt;img src=&quot;http://www.therealtimeweb.com/images/membermeister004.jpg&quot; /&gt;
&lt;p&gt;
Hopefully this saves someone some grief. Loading JSON from Rails seems well documented, and so ar 406 errors, but I had trouble finding the fix in this case because I wasn&apos;t 100% sure the issue was on the jQuery side...
				</description>
				
				<category>Rails</category>
				
				<category>JavaScript</category>
				
				<pubDate>Fri, 15 Mar 2013 06:36:00 +0100</pubDate>
				<guid>http://www.therealtimeweb.com/index.cfm/2013/3/15/rails-jquery-406</guid>
				
				
			</item>
			
			<item>
				<title>Ruby on Rails - Devise users/sign_out stops working</title>
				<link>http://www.therealtimeweb.com/index.cfm/2012/11/27/ror-devise-routing-error</link>
				<description>
				
				I&apos;m currently working on a Ruby on Rails (RoR) app together with a friend of mine - I&apos;m mainly handling the front end and hosting/config side of things whilst he is writing tons of Ruby code. I should add that we&apos;re using &lt;a href=&quot;http://twitter.github.com/bootstrap/&quot; target=&quot;_blank&quot;&gt;Twitter&apos;s bootstrap&lt;/a&gt; as a basis to style the application.&lt;p&gt;
I would like to draw your attention to an issue that had me stumped for half a day today (and a few hours yesterday) and it manifested itself in the following error upon clicking a sign out link (we&apos;re using Devise for user auth):&lt;p&gt;
&lt;code&gt;
No route matches [GET] &quot;/users/sign_out&quot;
&lt;/code&gt;
&lt;p&gt;
The obvious place to check was the routes, and indeed there was no GET route that matched. What should happen is that a DELETE request is fired once the user clicks the sign out link, which in turn is achieved by Rails&apos; JavaScript code modifying the request behind the scenes to make it RESTful (DELETE instead of GET).&lt;br&gt;
This topic of GET versus DELETE requests related to Devise sign outs is widely covered in posts such as &lt;a href=&quot;http://stackoverflow.com/questions/6965876/ruby-on-rails-devise-users-sign-out-not-working?rq=1&quot; target=&quot;_blank&quot;&gt;this one&lt;/a&gt; or &lt;a href=&quot;http://stackoverflow.com/questions/7465919/rails-link-to-method-geting-when-it-should-delete&quot; target=&quot;_blank&quot;&gt;this one&lt;/a&gt;.&lt;p&gt;
However this was not the issue we were seeing - it just looked very similar. It turned out that our version of Bootstrap which was a couple of months hold has a bug that stopped links inside nav dropdowns (if you use Bootstrap you know what I mean) with data-method attributes from working properly. 
&lt;p&gt;
Once I realised that Rails&apos; JS code inside jquery_ujs was no longer running when I clicked the link *inside* a nav dropdown but worked outside it I immediately googled for bootstrap related issues and found this &lt;a href=&quot;https://github.com/seyhunak/twitter-bootstrap-rails/issues/343&quot; target=&quot;_blank&quot;&gt;bug report&lt;/a&gt; which is also related to &lt;a href=&quot;https://github.com/twitter/bootstrap/issues/4688&quot; target=&quot;_blank&quot;&gt;this issue&lt;/a&gt;.&lt;p&gt;
In short, upgrading bootstrap to version 2.2.1 fixed the issue for us and links would now be processed properly, sending a DELETE request when needed. &lt;p&gt;
Hopefully this helps someone and saves them a few hours of grief - it was not the easiest bug to track down and fix.
				</description>
				
				<category>Rails</category>
				
				<pubDate>Tue, 27 Nov 2012 09:46:00 +0100</pubDate>
				<guid>http://www.therealtimeweb.com/index.cfm/2012/11/27/ror-devise-routing-error</guid>
				
				
			</item>
			</channel></rss>