<?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 on: Connecting to Multiple Databases Using ActiveRecord</title>
	<atom:link href="http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/</link>
	<description>Life &#38; Everything Else</description>
	<lastBuildDate>Wed, 10 Mar 2010 07:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nathan Zook</title>
		<link>http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/comment-page-1/#comment-32189</link>
		<dc:creator>Nathan Zook</dc:creator>
		<pubDate>Fri, 19 Feb 2010 19:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://frozenplague.net/?p=726#comment-32189</guid>
		<description>&lt;p&gt;AL:  Here&#039;s what you need:
class HR &lt; ActiveRecord::Base
  @abstract&lt;em&gt;class = true
  establish&lt;/em&gt;connection(:hr)
end&lt;/p&gt;

&lt;p&gt;My current employer is using four databases (on two servers).  I do the following:
class ApplicationModel &lt; ActiveRecord::Base
  @abstract_class = true&lt;/p&gt;

&lt;p&gt;def self.setup&lt;em&gt;connection
    base&lt;/em&gt;name = self.name.sub(/ConnectBase$/, &#039;&#039;)
    establish&lt;em&gt;connection(ActiveRecord::Base.configurations[&quot;#{base&lt;/em&gt;name.underscore}&lt;em&gt;#{RAILS&lt;/em&gt;ENV}&quot;])
  end
end&lt;/p&gt;

&lt;p&gt;class MyDBConnectBase &lt; ApplicationModel&lt;/p&gt;

&lt;p&gt;@abstract&lt;em&gt;class = true
  setup&lt;/em&gt;connection&lt;/p&gt;

&lt;p&gt;end&lt;/p&gt;

&lt;p&gt;Then all of my models inherit from one of the MyDBConnectBases.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>AL:  Here&#8217;s what you need:
class HR &lt; ActiveRecord::Base
  @abstract<em>class = true
  establish</em>connection(:hr)
end</p>

<p>My current employer is using four databases (on two servers).  I do the following:
class ApplicationModel &lt; ActiveRecord::Base
  @abstract_class = true</p>

<p>def self.setup<em>connection
    base</em>name = self.name.sub(/ConnectBase$/, &#8221;)
    establish<em>connection(ActiveRecord::Base.configurations["#{base</em>name.underscore}<em>#{RAILS</em>ENV}"])
  end
end</p>

<p>class MyDBConnectBase &lt; ApplicationModel</p>

<p>@abstract<em>class = true
  setup</em>connection</p>

<p>end</p>

<p>Then all of my models inherit from one of the MyDBConnectBases.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: AL</title>
		<link>http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/comment-page-1/#comment-24366</link>
		<dc:creator>AL</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:41:55 +0000</pubDate>
		<guid isPermaLink="false">http://frozenplague.net/?p=726#comment-24366</guid>
		<description>&lt;p&gt;Good tip. 
I was able to use establish_connection on the model class, but when I tried to use the extension example:&lt;/p&gt;

&lt;p&gt;class MCK &lt; ActiveRecord::Base
  establish_connection(:Mydb)
end&lt;/p&gt;

&lt;p&gt;class Mckuser &lt; MCK
end&lt;/p&gt;

&lt;p&gt;I get an error:&lt;/p&gt;

&lt;p&gt;Table &#039;Mydb.mcks&#039; doesn&#039;t exist: SHOW FIELDS FROM &lt;code&gt;mcks&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I place the mck.rb file on the lib folder.Any help would be appreciated&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Good tip. 
I was able to use establish_connection on the model class, but when I tried to use the extension example:</p>

<p>class MCK &lt; ActiveRecord::Base
  establish_connection(:Mydb)
end</p>

<p>class Mckuser &lt; MCK
end</p>

<p>I get an error:</p>

<p>Table &#8216;Mydb.mcks&#8217; doesn&#8217;t exist: SHOW FIELDS FROM <code>mcks</code></p>

<p>I place the mck.rb file on the lib folder.Any help would be appreciated</p>]]></content:encoded>
	</item>
	<item>
		<title>By: almost effortless &#187; Weekly Digest, 11-6-09</title>
		<link>http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/comment-page-1/#comment-24202</link>
		<dc:creator>almost effortless &#187; Weekly Digest, 11-6-09</dc:creator>
		<pubDate>Fri, 06 Nov 2009 20:27:44 +0000</pubDate>
		<guid isPermaLink="false">http://frozenplague.net/?p=726#comment-24202</guid>
		<description>&lt;p&gt;[...] Connecting to Multiple Databases Using ActiveRecord You can call establish_connection with the key that points to another database config in your config/database.yml file [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] Connecting to Multiple Databases Using ActiveRecord You can call establish_connection with the key that points to another database config in your config/database.yml file [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: mlambie</title>
		<link>http://ryanbigg.com/2009/10/connecting-to-multiple-databases-using-activerecord/comment-page-1/#comment-23732</link>
		<dc:creator>mlambie</dc:creator>
		<pubDate>Fri, 30 Oct 2009 06:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://frozenplague.net/?p=726#comment-23732</guid>
		<description>&lt;p&gt;Very cool Radar. I especially like extending AR::Base.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very cool Radar. I especially like extending AR::Base.</p>]]></content:encoded>
	</item>
</channel>
</rss>
