<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kevin Bedell on Internet Tech &#187; ruby on rails</title>
	<atom:link href="http://www.kbedell.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kbedell.com</link>
	<description>Discussions on Ruby on Rails, the MySQL database, Social Media, Twitter, Wordpress and other tech issues</description>
	<lastBuildDate>Wed, 30 Jun 2010 20:08:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to get the contents of the database.yml file from ActiveRecord</title>
		<link>http://www.kbedell.com/2009/03/06/how-to-get-the-contents-of-the-database-ml-file-from-activerecord-and-connect-to-two-databases-at-once/</link>
		<comments>http://www.kbedell.com/2009/03/06/how-to-get-the-contents-of-the-database-ml-file-from-activerecord-and-connect-to-two-databases-at-once/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 14:09:17 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=70</guid>
		<description><![CDATA[Save to delicious.
Sometimes when using Active Record you may want to create a database connection to a database other than the default database specified in your database.yml file.
When this happens, the easiest way to do it is to use the Class-level convenience method on ActiveRecord::Base. Like this:
Imagine your database.yml entry looks like this:
development_foo:
  adapter: [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://delicious.com/url/c5db65f90af6455a805484b6e7c67ccf">Save to delicious.</a></p>
<p>Sometimes when using Active Record you may want to create a database connection to a database other than the default database specified in your database.yml file.</p>
<p>When this happens, the easiest way to do it is to use the Class-level convenience method on ActiveRecord::Base. Like this:</p>
<p>Imagine your database.yml entry looks like this:</p>
<pre>development_foo:
  adapter: mysql
  encoding: utf8
  database: foo
  pool: 5
  username: my_user
  password: my_pass
  socket: /tmp/mysql.sock</pre>
<p>Now you want to create active record models that use that database connection. Here&#8217;s how:</p>
<pre># 'Bar' model points to the table 'bars' in the database 'foo'

class Bar &lt; ActiveRecord::Base

  # specify the database.yml entry
  $db_config = 'development_foo'

  # Fetch the database.yml configuration
  $config = ActiveRecord::Base.configurations[$db_config]

 # Now we can establish a connection to that database and
 # this ActiveRecord model class will point to that database.
  establish_connection $config

end</pre>
<p>It&#8217;s simple!</p>
<h6>Copyright Kevin Bedell, 2009<br />
All this code can be freely used under the terms of the MIT License.</h6>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2009/03/06/how-to-get-the-contents-of-the-database-ml-file-from-activerecord-and-connect-to-two-databases-at-once/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
