<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Dev411 Blog: ActiveRecord - Achilles Heel of Ruby on Rails?</title>
    <link>http://www.dev411.com/blog/2006/06/04/activerecord-achilles-heel-of-ruby-on-rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>John Wang on Technology</description>
    <item>
      <title>ActiveRecord - Achilles Heel of Ruby on Rails?</title>
      <description>&lt;p&gt;IMO, one of the major limitations of Ruby on Rails compared to other frameworks is its ORM, ActiveRecord. ActiveRecord is a fairly early ORM (object-relational mapper) that has made some questionable design decisions and doesn't support some very basic relational database concepts. These issues have been &lt;a href="http://discuss.joelonsoftware.com/default.asp?joel.3.309321.3"&gt;discussed on Joel on Software&lt;/a&gt; and elsewhere. Here are some limitations I wish were fixed:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;&lt;strong&gt;No Foreign Key Support:&lt;/strong&gt; Although RoR lets you define has_many relationships, it makes no effort to create foreign key constraints in the underlying database to ensure relational integrity.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;No Multi-column Primary Key Support:&lt;/strong&gt; Multi-column primary keys are a staple of relational database schema definition. Unfortunately, &lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/140320"&gt;DDH had a pretty simple response&lt;/a&gt;:
&lt;br /&gt;&lt;br /&gt;
&lt;em&gt;&amp;gt; Is there a way to set an ActiveRecord object to point to a table&lt;br /&gt;&amp;gt; with a multi-column primary key?
&lt;br /&gt;&lt;br /&gt;
Not really, no. Active Record was designed for a single column primary key and that assumption runs pretty deep. AR is not a Data Mapper, so you have to be within a reasonable vicinity of its
assumptions to enjoy it.&lt;br /&gt;- David Heinemeier Hansson&lt;/em&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;As DHH says in his multi-col PK response, you need to be close to ActiveRecord's assumptions, it doesn't cater to your situation. ActiveRecord is nice for many simpler situations but if you want relational integrity and/or have complex relationships, it seems like it may not be the best tool for the job. Other ORMs such as the Perl-based &lt;a href="http://search.cpan.org/~jrobinson/DBIx-Class-0.06003/lib/DBIx/Class.pm"&gt;DBIx::Class&lt;/a&gt; (often used with the &lt;a href="http://www.catalystframework.org"&gt;Catalyst framework&lt;/a&gt;) can handle these issues and many more. According to the 37Signals blog entry &lt;a href="http://www.37signals.com/svn/archives2/growing_in_vs_growing_out.php"&gt;Growing in vs. growing out&lt;/a&gt;, they prefer people to grow out of their applications. I'm curious if they also want people to grow out of ActiveRecord?&lt;/p&gt;</description>
      <pubDate>Sun, 04 Jun 2006 11:12:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a2217cbb03931530e0c28989c859cc6e</guid>
      <author>John Wang</author>
      <link>http://www.dev411.com/blog/2006/06/04/activerecord-achilles-heel-of-ruby-on-rails</link>
      <category>activerecord</category>
      <category>orm</category>
      <category>rails</category>
    </item>
    <item>
      <title>"ActiveRecord - Achilles Heel of Ruby on Rails?" by Prince Singh</title>
      <description>&lt;p&gt;ActiveScaffold does not work with Composite keys plugin mentioned above&lt;/p&gt;</description>
      <pubDate>Tue, 10 Jul 2007 11:27:32 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:43fee4ef-c08e-4642-817b-8d00deb41a1e</guid>
      <link>http://www.dev411.com/blog/2006/06/04/activerecord-achilles-heel-of-ruby-on-rails#comment-190</link>
    </item>
    <item>
      <title>"ActiveRecord - Achilles Heel of Ruby on Rails?" by John Wang</title>
      <description>&lt;p&gt;Thanks for posting. That looks very interesting. I hope composite PK support will get integrated into ActiveRecord proper since this is core functionality that I&amp;#8217;d rely on, not some add-on feature that I could just turn off in the event of future incompatibilities or other issues.&lt;/p&gt;</description>
      <pubDate>Sat, 26 Aug 2006 23:21:59 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3c5df9b5-51ad-4816-bf97-ba56510cb0a0</guid>
      <link>http://www.dev411.com/blog/2006/06/04/activerecord-achilles-heel-of-ruby-on-rails#comment-89</link>
    </item>
    <item>
      <title>"ActiveRecord - Achilles Heel of Ruby on Rails?" by Jack Hung</title>
      <description>&lt;p&gt;ActiveRecord composite primary keys extension available from Dr Nic Williams:&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://compositekeys.rubyforge.org/" rel="nofollow"&gt;http://compositekeys.rubyforge.org/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 26 Aug 2006 22:09:31 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:67dfb526-b8a7-4b73-af95-f581659c6862</guid>
      <link>http://www.dev411.com/blog/2006/06/04/activerecord-achilles-heel-of-ruby-on-rails#comment-88</link>
    </item>
  </channel>
</rss>
