<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for James Inman</title>
	<atom:link href="http://www.jamesinman.co.uk/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamesinman.co.uk</link>
	<description>A tumblelog.</description>
	<lastBuildDate>Thu, 05 Jan 2012 17:26:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>Comment on IR_Black For TextMate 2 by James</title>
		<link>http://www.jamesinman.co.uk/2011/12/ir_black-for-textmate-2/#comment-44</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 05 Jan 2012 17:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=116#comment-44</guid>
		<description>Glad it&#039;s useful!</description>
		<content:encoded><![CDATA[<p>Glad it&#8217;s useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on IR_Black For TextMate 2 by Sean P. Kane</title>
		<link>http://www.jamesinman.co.uk/2011/12/ir_black-for-textmate-2/#comment-43</link>
		<dc:creator>Sean P. Kane</dc:creator>
		<pubDate>Thu, 05 Jan 2012 17:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=116#comment-43</guid>
		<description>Thank you, thank you, thank you. Just what I was looking for.</description>
		<content:encoded><![CDATA[<p>Thank you, thank you, thank you. Just what I was looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on IR_Black For TextMate 2 by Jamie van Dyke</title>
		<link>http://www.jamesinman.co.uk/2011/12/ir_black-for-textmate-2/#comment-40</link>
		<dc:creator>Jamie van Dyke</dc:creator>
		<pubDate>Tue, 03 Jan 2012 00:11:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=116#comment-40</guid>
		<description>Thanks for this.  Although I had to remove the userstyle of bold on string, as it made them look a bit cludgy.</description>
		<content:encoded><![CDATA[<p>Thanks for this.  Although I had to remove the userstyle of bold on string, as it made them look a bit cludgy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on IR_Black For TextMate 2 by James</title>
		<link>http://www.jamesinman.co.uk/2011/12/ir_black-for-textmate-2/#comment-37</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 13 Dec 2011 19:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=116#comment-37</guid>
		<description>Added! :)</description>
		<content:encoded><![CDATA[<p>Added! <img src='http://www.jamesinman.co.uk/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on IR_Black For TextMate 2 by CB</title>
		<link>http://www.jamesinman.co.uk/2011/12/ir_black-for-textmate-2/#comment-36</link>
		<dc:creator>CB</dc:creator>
		<pubDate>Tue, 13 Dec 2011 19:19:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=116#comment-36</guid>
		<description>Screenshot?</description>
		<content:encoded><![CDATA[<p>Screenshot?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Serving One Rails Application With Multiple Databases by Brendon</title>
		<link>http://www.jamesinman.co.uk/2011/10/serving-one-rails-application-with-multiple-databases/#comment-14</link>
		<dc:creator>Brendon</dc:creator>
		<pubDate>Wed, 09 Nov 2011 07:41:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=78#comment-14</guid>
		<description>The code seems to have been stripped. Not sure how to post code in these comments, get in touch via email if you&#039;re interested.</description>
		<content:encoded><![CDATA[<p>The code seems to have been stripped. Not sure how to post code in these comments, get in touch via email if you&#8217;re interested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Serving One Rails Application With Multiple Databases by Brendon</title>
		<link>http://www.jamesinman.co.uk/2011/10/serving-one-rails-application-with-multiple-databases/#comment-13</link>
		<dc:creator>Brendon</dc:creator>
		<pubDate>Wed, 09 Nov 2011 07:40:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=78#comment-13</guid>
		<description>We did this with our Rails 2.3 app. I created a quick plugin that handled the switching code and also did the hijack at the start of the application controller. We use a central database that holds client data including a domain name to database mapping table. We initially connect to a known &#039;demo&#039; site database that we use for manual testing in production. I&#039;m currently looking to replicate this in a Rails 3.1 rewrite using sqlite3 database files instead of mysql database connections but here&#039;s our Rails 2.3 code if it helps. We found we needed to d more than just switch connections as we soon reached our connection limit as the old connections remained open indefinitely by default (though we changed this to have a timeout, we also now purposely close the original connection).

`module ActiveRecord
  module ConnectionAdapters
    class MysqlAdapter  db)
        reconnect!        
      end
      
      def restore_default_database!
        database = YAML::load(File.open(File.join(Rails.root, &#039;config/database.yml&#039;)))[Rails.env][&#039;database&#039;]
        change_database!(database)
      end
    end
  end
end`




  `prepend_before_filter :hijack_db
   
   def hijack_db
    ActiveRecord::Base.connection.change_database!(local_domain_hash)
  end`</description>
		<content:encoded><![CDATA[<p>We did this with our Rails 2.3 app. I created a quick plugin that handled the switching code and also did the hijack at the start of the application controller. We use a central database that holds client data including a domain name to database mapping table. We initially connect to a known &#8216;demo&#8217; site database that we use for manual testing in production. I&#8217;m currently looking to replicate this in a Rails 3.1 rewrite using sqlite3 database files instead of mysql database connections but here&#8217;s our Rails 2.3 code if it helps. We found we needed to d more than just switch connections as we soon reached our connection limit as the old connections remained open indefinitely by default (though we changed this to have a timeout, we also now purposely close the original connection).</p>
<p>`module ActiveRecord<br />
  module ConnectionAdapters<br />
    class MysqlAdapter  db)<br />
        reconnect!<br />
      end</p>
<p>      def restore_default_database!<br />
        database = YAML::load(File.open(File.join(Rails.root, &#8216;config/database.yml&#8217;)))[Rails.env]['database']<br />
        change_database!(database)<br />
      end<br />
    end<br />
  end<br />
end`</p>
<p>  `prepend_before_filter :hijack_db</p>
<p>   def hijack_db<br />
    ActiveRecord::Base.connection.change_database!(local_domain_hash)<br />
  end`</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Serving One Rails Application With Multiple Databases by James</title>
		<link>http://www.jamesinman.co.uk/2011/10/serving-one-rails-application-with-multiple-databases/#comment-7</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sun, 16 Oct 2011 01:18:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=78#comment-7</guid>
		<description>I&#039;m convinced there must be a nicer way around this than turning &lt;code&gt;config.cache_classes = true&lt;/code&gt; off though, simply due to the sheer performance hit that invokes.</description>
		<content:encoded><![CDATA[<p>I&#8217;m convinced there must be a nicer way around this than turning <code>config.cache_classes = true</code> off though, simply due to the sheer performance hit that invokes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Serving One Rails Application With Multiple Databases by Rahoul Baruah</title>
		<link>http://www.jamesinman.co.uk/2011/10/serving-one-rails-application-with-multiple-databases/#comment-5</link>
		<dc:creator>Rahoul Baruah</dc:creator>
		<pubDate>Sat, 15 Oct 2011 16:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamesinman.co.uk/?p=78#comment-5</guid>
		<description>Just to let you know I tried it on my app and it didn&#039;t help.  However, I&#039;m doing something slightly different, so I&#039;ll play around a bit further.</description>
		<content:encoded><![CDATA[<p>Just to let you know I tried it on my app and it didn&#8217;t help.  However, I&#8217;m doing something slightly different, so I&#8217;ll play around a bit further.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

