<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.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>Talk Like A Duck: Tag activerecord</title>
    <link>http://talklikeaduck.denhaven2.com/articles/tag/activerecord</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>Book Review: Pro Active Record</title>
      <description>&lt;a href="http://www.amazon.com/gp/product/1590598474?ie=UTF8&amp;tag=denhaven2com-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590598474"&gt;&lt;img border="0" src="http://talklikeaduck.denhaven2.com/files/2007-10-30_cover_of_pro_active_record.jpg" style='float:left;  margin-bottom:30px; margin-right:30px;'&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;l=as2&amp;o=1&amp;a=1590598474" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; 
I've been meaning to write a review of the recently published Apress book &lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FPro-Active-Record-Databases-Rails%2Fdp%2F1590598474%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1193756135%26sr%3D1-1&amp;tag=denhaven2com-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325"&gt;"Pro Active Record"&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;amp;l=ur2&amp;amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; by Kevin Marshall, Chad Pytel, and Jon Yurek for a while now. I have to admit that I was prompted to sit down and actually do it after reading &lt;a href="http://blog.hasmanythrough.com/2007/10/29/book-review-pro-active-record"&gt;Josh Susser's recent review of the same book.&lt;/a&gt;
&lt;p&gt;While I generally agree with Josh's assessment, We do differ a bit on which audience the book best serves.&lt;/p&gt;
&lt;p&gt;The goal of the book is to cover Active Record in depth, outside of the context of Rails.  The result, as I see it, is a book which is useful to intermediate to advanced users of Active Record, those who want to dig in to understanding the implementation and perhaps extending it.&lt;/p&gt;
&lt;p&gt;My own reading of the book gave me the impetus to explore the code of Active Record to the extent where I felt comfortable submitting contributions to Rails.  Since reading the book, I've written and submitted two active record patches to the Rails Trac. The &lt;a href="http://dev.rubyonrails.org/ticket/9971"&gt;first&lt;/a&gt; fixed an oversight which made the schema.db file dumped for MySQL tables with non-standard primary keys to lack those primary key declarations, and the second is an enhancement which allows the :joins option of methods like find and count in ActiveRecord::Base to take&lt;a href="http://dev.rubyonrails.org/ticket/10012"&gt; values like the :include option&lt;/a&gt; as an alternative to a sql joins clause string.  Both have made it into rails edge!&lt;/p&gt;



&lt;h2&gt;Pro Active Record for Beginners?&lt;/h2&gt;
&lt;p&gt;While I suppose that you could learn Active Record just from this book, I personally think that &lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FAgile-Web-Development-Rails-2nd%2Fdp%2F0977616630%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1193759512%26sr%3D1-1&amp;tag=denhaven2com-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325"&gt;Agile Web Development with Rails (2nd ed)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;amp;l=ur2&amp;amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; does a better job, and makes a better reference for everyday use of Active Record.  While not entirely devoted to Active Record, AWDWR devotes four chapters and 131 pages to it in the "Rails in Depth" section of the book, in addition to coverage of AR in the tutorial section.  In contrast, "Pro Active Record" comprises 8 chapters in 214 pages, plus a 52 page Appendix which is pretty much derived from the RDoc generated from the Active Record source code.&lt;/p&gt;
&lt;p&gt;Shortly after I bought the book, I was working on an issue with some active record validation callbacks on one of my projects. Since "Pro Active Record" was at hand I turned to it.  Although they have good coverage of the topic in Chapter 4, "Core Features of Active Record", the five pages of text description in PAR just doesn't make it as clear when particular callbacks will be called as the single chart on page 372 of the "Object Life Cycle" chapter in AWDWR.&lt;/p&gt;
&lt;p&gt;While some newcomers to active record who are using, say Camping, might welcome the "Rails-free" presentation of PAR, sometimes I get the impression that studiously eschewing Rails in this book hampers it just a bit. There sems to be a little too much repetition of things that Rails does for you, like ActiveRecord::Base.connect(...)&lt;/p&gt;
&lt;h2&gt;Digging In&lt;/h2&gt;
&lt;p&gt;That said, I do really like the book.  The chapter on dealing with legacy databases is quite useful, and I'd recommend it.&lt;/p&gt;
&lt;p&gt;The best part of the book was the section on extending AR. It gives a good introduction to the way AR works, it got me started actually reading the AR code in edge rails.  It also gives some good coverage of Ruby metaprogramming, particularly in the context of AR and Rails&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;So all in all, I recommend the book, although I would recommend newcomers to start with &lt;a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FAgile-Web-Development-Rails-2nd%2Fdp%2F0977616630%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1193759512%26sr%3D1-1&amp;tag=denhaven2com-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325"&gt;Agile Web Development with Rails (2nd ed)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;amp;l=ur2&amp;amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; even if they are using AR outside of rails.&lt;/p&gt;
&lt;p&gt;Those who are, or want to be, a little further along in their exploration, exploitation, and extension of Active Record will find it to be a valuable addition to their book shelf, just as I did.&lt;/p&gt;</description>
      <pubDate>Tue, 30 Oct 2007 12:31:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:bacdbcc3-19b3-4cd9-87fd-2ecae8c6c150</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/10/30/book-review-pro-active-record</link>
      <category>book_reviews</category>
      <category>rails</category>
      <category>activerecord</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/476</trackback:ping>
    </item>
    <item>
      <title>Active Record and Referential Integrity</title>
      <description>Josh Susser just posted a new Rails plugin &lt;a href="http://blog.hasmanythrough.com/2007/7/14/validate-your-existence"&gt;which adds a validates_existence_of method to ActiveRecord::Base.&lt;/a&gt;.  The idea is that beyond validates_presence_of, which simply checks that a foreign key field is non-nil, or validates_associated which &lt;strong&gt;validates&lt;/strong&gt; the model referenced by a foreign key, validate_existence ensures that the referenced model &lt;strong&gt;exists&lt;/strong&gt; in the database, no more no less.
&lt;p&gt;It&amp;#8217;s brand new, but it sure looks like a nice idea.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Jul 2007 15:10:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:55d910e3-af16-4d61-9fbe-26a3c0ecba51</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/07/14/active-record-and-referential-integrity</link>
      <category>rails</category>
      <category>activerecord</category>
      <category>referential_integrity</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/442</trackback:ping>
    </item>
  </channel>
</rss>
