<?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>dicianno.org/blog &#187; web</title>
	<atom:link href="http://dicianno.org/blog/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://dicianno.org/blog</link>
	<description>notes about computers and lifestyle</description>
	<lastBuildDate>Thu, 04 Feb 2010 21:09:05 +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>Rails and &#8220;legacy&#8221; DB&#8217;s</title>
		<link>http://dicianno.org/blog/2007/06/17/rails-and-legacy-dbs/</link>
		<comments>http://dicianno.org/blog/2007/06/17/rails-and-legacy-dbs/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 05:18:51 +0000</pubDate>
		<dc:creator>armando</dc:creator>
				<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.dicianno.org/blog/2007/06/17/rails-and-legacy-dbs/</guid>
		<description><![CDATA[I&#8217;m importing a (so-called) &#8220;legacy&#8221; db, and was having some issues with creating associations because the primary key wasn&#8217;t named id.  To fix this, simply use set_primary_key on the class, and then use foreign_key to create associations between classes as usual.



class LegacyDatabaseTable &#60; ActiveRecord::Base


&#160; set_primary_key :this_is_not_named_id


&#160; # &#8230;


end



]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m importing a (so-called) &#8220;legacy&#8221; db, and was having some issues with creating associations because the primary key wasn&#8217;t named <strong>id</strong>.  To fix this, simply use <strong>set_primary_key</strong> on the class, and then use <strong>foreign_key</strong> to create associations between classes as usual.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">class</span> LegacyDatabaseTable &lt; <span class="re2">ActiveRecord::Base</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; set_primary_key <span class="re3">:this_is_not_named_id</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1"># &#8230;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dicianno.org/blog/2007/06/17/rails-and-legacy-dbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

