<?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>Zak Mandhro &#187; rails</title>
	<atom:link href="http://mandhro.com/category/ruby/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://mandhro.com</link>
	<description>technology = evolution; open source = punctuated equilibrium</description>
	<lastBuildDate>Mon, 13 Jul 2009 07:50:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Family2.0 Famiva is live, FINALLY!</title>
		<link>http://mandhro.com/2007/03/21/family20-famiva-is-live-finally/</link>
		<comments>http://mandhro.com/2007/03/21/family20-famiva-is-live-finally/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 18:00:34 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[social networks]]></category>

		<guid isPermaLink="false">http://mandhro.com/2007/03/21/family20-famiva-is-live-finally/</guid>
		<description><![CDATA[After many months of working nights and weekends, Famiva is finally ready for public beta! So, what is Famiva anyway? It&#8217;s a free social network and collaboration service for families. Basically, it&#8217;s a web site that allows you build your family tree. Every relative you add will get the ability to complete their family tree [...]]]></description>
			<content:encoded><![CDATA[<p>After many months of working nights and weekends, Famiva is finally ready for public beta! So, what is Famiva anyway? It&#8217;s a free social network and collaboration service for families. Basically, it&#8217;s a web site that allows you build your family tree. Every relative you add will get the ability to complete their family tree by adding their relatives, and so on. Everyone works together and collaborates to build the &#8220;family network&#8221;.</p>
<p>Famiva is also a private portal. Features include photo sharing, comments, member profiles, family calendar, maps of photos and people, stories, events, reminders and more. The family network is tightly integrated with tools that let you share information with your extended family, keep track of who&#8217;s who and what&#8217;s going with everyone. For example, click on a member anywhere to see profile, their immediate family, the 3-level family tree or the entire family network. You can relate photos and stories to people, see them on the world map, etc.</p>
<p>I think Famiva demonstrates how Ruby on Rails can be used to develop complex web applications with non-trivial data structures (graphs) and Java integration. It also a nice use case for Ajax, Google Maps and Flickr integration.</p>
<p>To learn more about Famiva, check it out for yourself at <a href="http://famiva.com">http://famiva.com</a> and visit the <a href="http://blog.famiva.net">Famiva Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2007/03/21/family20-famiva-is-live-finally/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Edgy on Rails? Get compiling!</title>
		<link>http://mandhro.com/2007/01/11/edgy-on-rails-get-compiling/</link>
		<comments>http://mandhro.com/2007/01/11/edgy-on-rails-get-compiling/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 03:58:57 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandhro.com/2007/01/11/edgy-on-rails-get-compiling/</guid>
		<description><![CDATA[Love Ubuntu and want to run a Rails server on Edgy Eft (Ubuntu 6.10)? Roll-up your sleeves for some "compiling from source" fun.
Please note that Ubuntu Fiesty Fawn has been released. It comes with Apache 2.2. If you can, avoid all this compiling and just sudo apt-get dist-upgrade!
Rails development on Ubuntu is a breeze, you [...]]]></description>
			<content:encoded><![CDATA[<p>Love Ubuntu and want to run a Rails server on Edgy Eft (Ubuntu 6.10)? Roll-up your sleeves for some "compiling from source"<em> fun.</p>
<p></em><em>Please note that Ubuntu Fiesty Fawn has been released. It comes with Apache 2.2. If you can, avoid all this compiling and just <strong>sudo apt-get dist-upgrade</strong>!</em></p>
<p>Rails development on Ubuntu is a breeze, you can <em>apt-get</em> all the stuff you need. From Ruby 1.8.4 and MySQL driver to ImageMagick, the official repositories have got you covered. Deployment is another story. The bad news is that stuff that comes with Edgy just doesn't work, the good news, compiling stuff in Ubuntu, and Debian in general, is really easy.<br />
Where's what we need to compile:</p>
<ul>
<li><a href="#apache">Apache 2.2</a></li>
<li><a href="#pound">Pound</a></li>
<li><a href="#memcached">Memcached</a></li>
</ul>
<h3>Apache 2.2</h3>
<p><a name="apache"></a><a name="apache"></a>Because you can't do serious Rails deployment without a <a target="_blank" href="http://mongrel.rubyforge.org">Mongrel</a> <a target="_blank" href="http://mongrel.rubyforge.org/docs/mongrel_cluster.html">cluster</a>, and Mongrel needs a Load Balancing Proxy so that browsers can connect to the standard port 80. Ubuntu comes with Apache 2.0, which is no good because <a target="_blank" href="http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html">mod_proxy_balancer</a> was not introduced until Apache 2.2. We need to grab Apache 2.2.x from <a href="http://httpd.apache.org/download.cgi">the source</a> and compile it ourselves.</p>
<p>Note: You _can_ use <a target="_blank" href="http://www.lighttpd.net/">lighttpd</a> but I wouldn't use it's mod_proxy plug-in. Why? Because it's load balancing bit is buggy and <a target="_blank" href="http://mongrel.rubyforge.org/docs/lighttpd.html">Zed says so</a>. If you must use lighty, use Pound to do the load balancing (see below).</p>
<p>No point re-inventing the wheel, the good folks at Starman will <a target="_blank" href="http://www.rubystarman.org/wiki/UbuntuEdgyEft">show you how</a> to build Apache 2.2. Don't have time to read? Simply get the latest Unix source from the Apache download site. Get some stuff from Ubuntu universe:</p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo apt-get install build-essential libpcre3-dev libssl-dev libdb4.<span style="color:#800000;color:#800000;">3</span>-dev libneon25-dev </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Remove existing Apache package, untar the Apache source and run:</p>
<div class="igBar"><span id="lcode-7"><a href="#" onclick="javascript:showPlainTxt('code-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-7">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./configure --enable-deflate --enable-proxy --enable-proxy-html --enable-proxy-balancer --enable-rewrite --enable-cache --enable-mem-cache --enable-ssl --enable-headers --enable-logio </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Followed by</p>
<div class="igBar"><span id="lcode-8"><a href="#" onclick="javascript:showPlainTxt('code-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-8">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">make ; sudo make install </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This will install Apache 2.2.3 in /usr/local, which is where I like it because it doesn't get confused with Ubuntu maintained stuff. You will have to point your /etc/init.d/apache to the new apachectl.</p>
<h3>Pound</h3>
<p><a name="pound"></a><a target="_blank" href="http://www.apsis.ch/pound/">Pound</a> is a decent standalone load balancer. You can learn more about using <a target="_blank" href="http://mongrel.rubyforge.org/docs/pound.html">Pound with Mongrel here</a>. One advantage here is that you can use lighttpd as a web server + proxy and let Pound do the balancing. It is quite configurable and comes standard with Ubuntu. Well, sort of. The  Ubuntu Edgy package doesn't work very well. In my case, it kept crashing without any warnings.  If you do want Pound, you will have to compile from source. Rob Orsini explains how to setup <a target="_blank" href="http://blog.tupleshop.com/2006/7/8/deploying-rails-with-pound-in-front-of-mongrel-lighttpd-and-apache">lighty, Pound and Mongrel</a> here. Long story short, <a target="_blank" href="http://www.apsis.ch/pound/Pound-2.2.tgz">download Pound</a> and untar (tar xfz) it.</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo apt-get install libpcre3 libpcre3-dev</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./configure; make ; sudo make install </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Memcached</h3>
<p><a name="memcached"></a>Memcached is an in-memory cache that can help take the load off your database. I was attempting to use memcache as my Rails session store but the standard Edgy package refused to work for me. Rails would complain that my session was expiring within a few navigations. This would only occur under a Mongrel cluster; a single Mongrel or Webrick would have no problems. Strange.</p>
<p><a name="memcached"></a><a name="memcached"></a>So I got the <a target="_blank" href="http://www.danga.com/memcached/download.bml">latest memcached source</a> and repeated the compile drill:</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo apt-get install libevent-dev</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./configure; make; sudo make install </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This fixed the problem but for some reason memcached would occasionally halt for several seconds, making my site slower rather than faster. I finally gave up on memcached and decided to settle for <a target="_blank" href="http://railsexpress.de/blog/articles/2006/09/15/sqlsessionstore-now-available-as-a-plugin">SqlSessionStore</a>, which works like a champ! If any of you have insight or experience with this issue, please let me know.</p>
<p>All this compiling, albeit easy, should not be needed. The biggest downside of compiling is that you don't get to apt-get upgrade things. You could be missing out on a critical patch. If only the Ubuntu package maintainers would stay current, or someone (like you and me) would just take some time to build DEBs and publish a "Ubuntu on Rails" repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2007/01/11/edgy-on-rails-get-compiling/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SD Times &#8211; Rails for Tactical Business Applications</title>
		<link>http://mandhro.com/2007/01/11/sd-times-rails-for-tactical-business-applications/</link>
		<comments>http://mandhro.com/2007/01/11/sd-times-rails-for-tactical-business-applications/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 03:44:25 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[enterprise]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandhro.com/2007/01/11/sd-times-rails-for-tactical-business-applications/</guid>
		<description><![CDATA[SD Times recently published my article on Tactical Business Applications with Ruby on Rails.  It discusses the advantages of using Rails to fulfill enterprise business needs.
Get the full article here: SD Times - Rails for Tactical Business Applications
]]></description>
			<content:encoded><![CDATA[<p>SD Times recently published my article on Tactical Business Applications with Ruby on Rails.  It discusses the advantages of using Rails to fulfill enterprise business needs.</p>
<p>Get the full article here: <a href="http://www.sdtimes.com/printArticle/column-20070101-01.html">SD Times - Rails for Tactical Business Applications</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2007/01/11/sd-times-rails-for-tactical-business-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using MySQL Full Text Search with Rails</title>
		<link>http://mandhro.com/2006/11/20/using-mysql-full-text-querying-with-rails/</link>
		<comments>http://mandhro.com/2006/11/20/using-mysql-full-text-querying-with-rails/#comments</comments>
		<pubDate>Mon, 20 Nov 2006 21:40:04 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.mandhro.com/2006/11/20/using-mysql-full-text-querying-with-rails/</guid>
		<description><![CDATA[MySQL offers powerful out-of-the-box full text search capability. It allows you to do advanced search on text columns such as:
apple +computer -fruit
As of Rails 1.1.6, working with MySQL Full Text search is not that straight forward. The first problem is that Migrations doesn't support the SQL syntax for full text indexes. Your create table class [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL offers powerful <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html">out-of-the-box full text search</a> capability. It allows you to do advanced search on text columns such as:</p>
<blockquote><p>apple <strong>+</strong>computer <strong>-</strong>fruit</p></blockquote>
<p>As of Rails 1.1.6, working with MySQL Full Text search is not that straight forward. The first problem is that Migrations doesn't support the SQL syntax for full text indexes. Your create table class has to to two things.</p>
<ol>
<li>Set the table options to "ENGINE=MyISAM"; the default InnoDB doesn't support FULL TEXT.</li>
<li>Execute the native DML to create the INDEX.</li>
</ol>
<p>Here's a complete example:</p>
<div class="igBar"><span id="lruby-13"><a href="#" onclick="javascript:showPlainTxt('ruby-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-13">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">create_table<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"stories"</span>, :force =&gt; <span style="color:#0000FF; font-weight:bold;">true</span>, : options=&gt; <span style="color:#996600;">"ENGINE=MyISAM"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">t.<span style="color:#9900CC;">column</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"subject"</span>, :<span style="color:#CC0066; font-weight:bold;">string</span>, :limit =&gt; <span style="color:#006666;color:#800000;">150</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">t.<span style="color:#9900CC;">column</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"created_at"</span>, :timestamp<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">t.<span style="color:#9900CC;">column</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"created_by_member_id"</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span>, :limit =&gt; <span style="color:#006666;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">t.<span style="color:#9900CC;">column</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"happened_on"</span>, :date<span style="color:#006600; font-weight:bold;">&#41;</span>&nbsp; &nbsp;t.<span style="color:#9900CC;">column</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"body"</span>, :text<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">add_index <span style="color:#996600;">"stories"</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">"created_by_member_id"</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#Create MySQL specific full-text index</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">execute <span style="color:#996600;">"CREATE FULLTEXT INDEX FullText_Stories ON stories (subject, body)"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>That takes care of the Migration part. No big deal, you can't expect Migrations to support all the specific features of all database engines. The second problem has to do with Unit Testing. Rails schema dumper will fail to recognize the full text index and will try to generate a regular index. However, MySQL will not like creating an index on the TEXT data type, and your full text tests will fail as well.To resolve this problem, we will have to <strike>fix</strike>enhance the schema dumper located at ./active-record-1.*.*/lib/active_record/schema_dumper.rb under your Ruby gems or vendor (if you've frozen Rails) directory. The adapter can not tell us if we are using full text index, so we'll have to improvise and use a naming convention. Assuming all your full text indexes are prefixed with "FullText_", we can check for it and generate the appropriate schema.rb.</p>
<p>Here's the replacement code for the indexes method in schema_dumper.rb:</p>
<div class="igBar"><span id="lruby-14"><a href="#" onclick="javascript:showPlainTxt('ruby-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-14">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> indexes<span style="color:#006600; font-weight:bold;">&#40;</span>table, stream<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">indexes = @connection.<span style="color:#9900CC;">indexes</span><span style="color:#006600; font-weight:bold;">&#40;</span>table<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">indexes.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |index|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">if</span> index.<span style="color:#9900CC;">name</span>=~/FullText_/ <span style="color:#9966CC; font-weight:bold;">and</span> @connection.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>ActiveRecord::ConnectionAdapters::MysqlAdapter<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stream.<span style="color:#CC0066; font-weight:bold;">puts</span> &lt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">execute <span style="color:#996600;">"ALTER TABLE #{index.table} ENGINE = MyISAM"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">execute <span style="color:#996600;">"CREATE FULLTEXT INDEX #{index.name} ON #{index.table} (#{index.columns.join(',')})"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RUBY</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">else</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stream.<span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#996600;">"&nbsp; add_index #{index.table.inspect}, #{index.columns.inspect}, :name =&gt; #{index.name.inspect}"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stream.<span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#996600;">", :unique =&gt; true"</span> <span style="color:#9966CC; font-weight:bold;">if</span> index.<span style="color:#9900CC;">unique</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stream.<span style="color:#CC0066; font-weight:bold;">puts</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stream.<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#9966CC; font-weight:bold;">unless</span> indexes.<span style="color:#9900CC;">empty</span>?</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We check to make sure the database adapter is MySQL for good measure. That should do the trick. But wait! Don't modify the Rails code, use the plug-in instead! You can download the Rails 1.1.6 plug-in <a href="http://www.mandhro.com/wp-content/uploads/2006/11/ar_mysql_full_text.zip">here.</a> Drop it in your Rails vendor directory and enjoy full-text search with MySQL.</p>
<p><strong><a id="p12" onmousedown="selectLink(12);" href="http://www.mandhro.com/wp-content/uploads/2006/11/ar_mysql_full_text.zip">ActiveRecord MySQL Full Text Plugin</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2006/11/20/using-mysql-full-text-querying-with-rails/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Publising Rails Plug-ins with Rake</title>
		<link>http://mandhro.com/2006/07/03/publising-rails-plug-ins-with-rake/</link>
		<comments>http://mandhro.com/2006/07/03/publising-rails-plug-ins-with-rake/#comments</comments>
		<pubDate>Mon, 03 Jul 2006 16:05:13 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.mandhro.com/2006/07/03/publising-rails-plug-ins-with-rake/</guid>
		<description><![CDATA[Problem: The Ruby on Rails plug-in installer's RecursiveHTTPFetcher makes certain assumptions about web servers that does not hold true from server to server. For example, it assumes:

The web server has "file browsing" enabled
All links to plug-in files are relative
Folder links end with a forward slash

RubyForge web server is an example of where these assupmtions don’t [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong>The <a href="http://rubyonrails.org">Ruby on Rails</a> plug-in installer's <em>RecursiveHTTPFetcher</em> makes certain assumptions about web servers that does not hold true from server to server. For example, it assumes:</p>
<ul>
<li>The web server has "file browsing" enabled</li>
<li>All links to plug-in files are relative</li>
<li>Folder links end with a forward slash</li>
</ul>
<p><a href="http://rubyforge.org">RubyForge</a> web server is an example of where these assupmtions don’t hold true. As a result, you can not simply copy your files to a web server and expect Rails HTTP plugin installer to just work.</p>
<p><strong>Solution: Rails Plug-in Package Task</strong></p>
<p><a href="http://www.mandhro.com/wp-content/uploads/2006/07/RailsPluginPackageTask.zip">RailsPluginPackageTask</a> is a Rake task designed to automate the publishing of Ruby on Rails plug-ins. It helps fill the gap by conforming to the Rails plug-in script's assumptions. Following the <a href="file:///devbox/projects/rubyforge/roxml/rake/doc/classes/Rake.html">Rake</a> package task conventions, it defines the "rails_plugin" task that recurses through your <em>package_files</em>, generates compliant index.html for each folder (that contains a file), and creates a directory structure that you can publish as a set for your plugin.</p>
<p><strong>Example</strong></p>
<p>The following example uses the <a href="http://www.mandhro.com/wp-content/uploads/2006/07/RailsPluginPackageTask.zip">Rake::RailsPluginPackageTask</a> to create the package. It then uses the Rake::SshDirPublisher to publish the plugin directory to RubyForge.</p>
<div class="igBar"><span id="lruby-16"><a href="#" onclick="javascript:showPlainTxt('ruby-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-16">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Rake::RailsPluginPackageTask.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>ProjectInfo<span style="color:#006600; font-weight:bold;">&#91;</span>:name<span style="color:#006600; font-weight:bold;">&#93;</span>, ProjectInfo<span style="color:#006600; font-weight:bold;">&#91;</span>:version<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |p|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">package_files</span> = PluginPackageFiles</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">plugin_files</span> = FileList<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">"rails_plugin/**/*"</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">extra_links</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">"Project page"</span>=&gt;ProjectInfo<span style="color:#006600; font-weight:bold;">&#91;</span>:homepage<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#996600;">"Author: #{ProjectInfo[:author_name]}"</span>=&gt;ProjectInfo<span style="color:#006600; font-weight:bold;">&#91;</span>:author_link<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">verbose</span> = <span style="color:#0000FF; font-weight:bold;">true</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">task :rails_plugin=&gt;:clobber</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">desc <span style="color:#996600;">"Publish Ruby on Rails plug-in on RubyForge"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">task :release_plugin=&gt;:rails_plugin <span style="color:#9966CC; font-weight:bold;">do</span> |task|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pub = Rake::SshDirPublisher.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"#{RubyForgeConfig[:user_name]}@rubyforge.org"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#996600;">"/var/www/gforge-projects/#{RubyForgeConfig[:unix_name]}"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#996600;">"pkg/rails_plugin"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">pub.<span style="color:#9900CC;">upload</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>You can download the <a href="http://www.mandhro.com/wp-content/uploads/2006/07/RailsPluginPackageTask.zip">ZIP package</a> for this task and place it in your gems or project folder. For a complete working example, checkout <a target="_blank" href="http://rubyforge.org/scm/?group_id=305">ROXML from CVS</a>.</p>
<p>Note: This release has only been tested on Linux. If it doesn't work on your OS, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2006/07/03/publising-rails-plug-ins-with-rake/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Designing Databases with ActiveRecord Conventions</title>
		<link>http://mandhro.com/2006/06/16/designing-databases-with-activerecord-conventions/</link>
		<comments>http://mandhro.com/2006/06/16/designing-databases-with-activerecord-conventions/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 21:33:44 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.mandhro.com/?p=5</guid>
		<description><![CDATA[Based on Ruby on Rails  Philosophy and ActiveRecord  Default Naming Standards
Underlying Philosophy
The goal of IT systems is to provide support the business objectives. IT departments have been guilty of focusing too much on their individual function, such as database administration or Java development, digressing into engineering perfect and losing focus of the bigger [...]]]></description>
			<content:encoded><![CDATA[<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.rubyonrails.org/images/rails.png"><img border="0" style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 41px; height: 53px" src="http://www.rubyonrails.org/images/rails.png" /></a>Based on <a href="http://rubyonrails.org/">Ruby on Rails </a> Philosophy and <a href="http://wiki.rubyonrails.org/rails/pages/ActiveRecord">ActiveRecord </a> Default Naming Standards</p>
<h4>Underlying Philosophy</h4>
<p>The goal of IT systems is to provide support the business objectives. IT departments have been guilty of focusing too much on their individual function, such as database administration or Java development, digressing into engineering perfect and losing focus of the bigger IT objectives. New conventions are emerging in the software development industry that are breaking old monolithic standards and promoting a more holistic view of the software development functions, with the goal of efficiently delivering business value.</p>
<p>Databases serve a specific purpose in the enterprise: to store and retrieve data so that user-facing services, such as application and business intelligence tools, can meet the business needs efficiently. In other words, if a database design reduces the development time for building a specific application or report while meeting the business objectives, than it should be designed as such, even if it doesn't follow old (and often unnecessary) conventions. Ruby on Rail's ActiveRecord framework supports such a convention; it promotes a common-sense approach to building databases that accelerate application and report development while meeting long-term business objectives.</p>
<h4>A note on Oracle limitations</h4>
<p>Oracle identifiers (table/column names) are limited to 30 characters, which creates unwarranted tendency to abbreviate identifiers, and create artificial and often cryptic naming conventions. If you are concerned about Oracle's column name length, you'll be surprised how much you can fit into 30 characters by using good logical names. In many cases, a very long column name is a sign of normalization problem:</p>
<ul>
<li>FIRST_INVOICE_CREATED_ON</li>
<li>CONTRACTOR_POINT_OF_CONTACT</li>
</ul>
<h4>What about Internationalization (<a href="http://en.wikipedia.org/wiki/Internationalization">I18N</a>)?</h4>
<p>The objective of these conventionss is not to eliminate the need for translation of labels. These naming conventions will help you standardize around names that are logical, readable and consistent. Depending on your development environment, it may even help your tool translate your database objects names into your application or report development namespace.</p>
<h3><span style="font-size: 100%">1. Table Names</span></h3>
<h4>Convention #1.1 – Naming tables</h4>
<p>A database row represents one instance of an entity, while a table is a collection of the same entities. Use plural nouns, e.g. PEOPLE, CONTRACTS, etc for database tables - this follows the common database convention. Use underscore to separate words, e.g. LINE_ITEMS. Do not abbreviate. Do not start table names with a number – this causes errors in certain application platforms. Do not use prefixes like REF_ or LU_ for reference tables, entity names should represent the information being stored, and not try to represent a usage scenario for the information.</p>
<p>Alternatively, you can use the singular form of entity names for tables, thereby following the Object Oriented Programming naming style and avoiding the need for translation from singular to plural and vice versa. ActiveRecord defaults to plural table names, this can be turned off as a <a href="http://wiki.rubyonrails.org/rails/pages/Turn/versions/8">global environment setting</a>.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>PEOPLE</li>
<li>PERSON</li>
<li>LINE_ITEMS</li>
<li>ORDER_TYPES, TYPES_OF_ORDERS</li>
</ul>
<p><strong>Not recommended</strong>:</p>
<ul>
<li>LINEITEMS</li>
<li>LN_ITEMS</li>
<li>LI</li>
<li>REF_ORDER_TYPE</li>
<li>ORDER_TP_CDS</li>
</ul>
<h4>Convention #1.2 – Naming association tables</h4>
<p>For association tables (also known as intersection tables) that resolve many-to-many relationships, use the following naming convention: [name of first entity]_[name of second entity]. This may not always be possible, given Oracle's limitation. Use it whenever possible, it makes it easier to identify the physical translation of a logical relationship.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>PRODUCTS_CATEGORIES</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>PROD_CATEGORY_INT</li>
<li>PRODUCT_CATEGORY_XREF</li>
</ul>
<h4>Convention #1.3 – Proper use of schemas</h4>
<p>Do not put application prefixes on table names for business data – this tightly couples business data to applications. Business data is a function of the business, not the application. There is always a logical name for business entities. Use schemas for the intended purpose of creating namespaces, to logically group relates entities and avoid naming conflicts.</p>
<p><em>Do not use a master schema that holds all tables, it is an anti-pattern and defeats the purpose of schemas.</em></p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>ACCOUNTING.ACCOUNTS</li>
<li>PHONE_BOOK.POINTS_OF_CONTACTS</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>ACCOUNTING_ACCOUNT</li>
<li>ACT_ACCOUNTS</li>
<li>PB_POCS</li>
</ul>
<p>There are other obvious advantages of using schemas for logical grouping. For examples, schema level security policies simplify access control, storage settings can be defined at the schema level. In general, schemas and all objects within schema can be administered using schema-level operations.</p>
<p>Use a separate schema for development and testing, this way your test database can be wiped out or stages for automated unit tests and for testing reports. Use “_DEV” and “_TEST” suffix with the schema name to differentiate. Production schema name should match the logical name; it <strong>should not</strong> have a suffix.</p>
<h3><span style="font-size: 85%">Primary Keys and Foreign Keys</span></h3>
<h4>Convention #2.1 – Using numeric primary keys</h4>
<p>Always use auto incremented numeric primary key. For consistency and simplicity, I recommend ‘ID'. It is a noun as defined in English language as a synonym to <em>identity </em>. Also, some frameworks, such as ActiveRecord, use ID as the default name for primary key.</p>
<p>Use auto increment (sequences) as a general rule, unless you want the application tier to manage the keys. Even the most obvious business keys can change, for example, DUNS number for identifying partners. If and when the business key changes, all the relationships will break. Business keys are pieces of business data that should have unique constraints.</p>
<p>Using numeric IDs makes database indexes more efficient. Strings, for instance, take more space to store than numbers. This space is saved in index storage, the space saving is propagated to all child tables' foreign keys.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>ID (INT) AUTO INCREMENT</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>CUSTOMER_ID</li>
<li>TYPE_CODE</li>
<li>EMAIL_ADDRESS</li>
<li>SSN</li>
<li>ISBN</li>
<li>DUNS</li>
</ul>
<h4>Convention #2.2 – Using single column keys</h4>
<p>This convention is an extension of 2.1. Avoid concatenated keys at all costs. Concatenated keys complicate indexes and all DML statements. They take more space to store and index. The storage need and SQL complexity multiplies with every child table (the entire multi-column key has to be stored in every child table). Moreover, concatenated keys make object relational mapping complicated and error-prone. Follow this convention in conjunction with 2.1, use single integer primary keys – auto incremented whenever possible.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>ID (INT) AUTO INCREMENT</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>ORDER_DATE + CUSTOMER_ID</li>
<li>FIRST_NAME + LAST_4_SSN</li>
</ul>
<h4>Convention #2.3 – Naming foreign keys</h4>
<p>This may sound like a violation of convention #2.2 and general principle of using logical names. The logic behind this convention is that all relationships can be named as one of the three types of associations:</p>
<ol>
<li>Entity A belongs to Entity B (child to parent)</li>
<li>Entity A has zero, one or many Entity Bs (parent to child)</li>
<li>Entity A has many and belongs to many Entity Bs (many to many)</li>
</ol>
<p>If you use the above listed logical names for foreign key naming, the column name will not tell you which entity it is associating the entity with. This becomes a bigger problem when you have a child table with multiple parents, e.g. an order_items table could have a foreign key to an order and discount type.</p>
<p>ActiveRecord recommends using the following convention: [parent entity name]_ID. The advantage of using this convention is that you can tell the parent entity, direction and type of the association.</p>
<p>There is a downside to this naming convention; the column name does not tell you the nature of the association. For example, an employee can have two circular relationships, “reports to employee” and “mentored by employee.” In these kinds of scenarios, you can either extract the foreign key/keys into an association table, or use the following convention: [nature of association]_[name of parent entity]_ID.</p>
<p>I don't feel strongly about this convention, feel free to adopt any one standard and use it consistently; keep in mind that several Object Relational Mapping can infer the relationship if you follow the ActiveRecord convention of [parent entity name]_ID.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>ORDER_ID</li>
<li>REPORTS_TO_EMPLOYEE_ID</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>FK_ORDER</li>
<li>ORDER</li>
<li>REPORTS_TO_EMPLOYEE</li>
</ul>
<h3><span style="font-size: 100%">Column names</span></h3>
<p>Column names should be the logical name of the attribute. A good rule to follow is that the column name should be obvious to the end users; there should be no need to translate the name before it is presented in a report of application. This simple principal will not only add clarity to your database schemas, it will alleviate the need for maintaining application labels (unless your application supports multiple languages). You will also alleviate the need for meta-data for ad hoc reporting tools.</p>
<p>The remaining conventions are an extension and elaboration of this general principal.</p>
<h4>Convention #3.1 – Naming columns</h4>
<p>Underscores serve as a friendly visual delimiter for words. Some databases allow spaces and mixed case in table names but most popular databases suppress this capability by default. For a standard approach that can be applied to all databases, use upper-case table names with underscores to separate words.</p>
<p>Frameworks like ActiveRecord can translate logical column names into object attributes and/or user interface labels using the following rules:</p>
<ol>
<li>First letter of each word will be capitalized</li>
<li>Underscore is translated to a space and used as a delimiter for words</li>
</ol>
<p>As an example, a column named “FIRST_NAME” will translate to “First Name” on the user interface.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>FIRST_NAME</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>FIRSTNAME</li>
<li>F_NAME</li>
<li>FIRST_NM</li>
</ul>
<h4>Convention #3.2 – Avoid table names in column names</h4>
<p>The table name specifies the context for the columns. Prefixing column names with table name is redundant. If you find a column name to be ambiguous without the table name, you may want to review your data model for normalization.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>CUSTOMERS.NAME (Table CUSTOMERS Column NAME)</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>CUSTOMERS.CUSTOMER_NAME<br />
(Table CUSTOMERS Column CUSTOMER_NAME)</li>
</ul>
<h4>Convention #3.3 – Avoid data type names in column names</h4>
<p>Column data type is specified by the column definition in the table. Using type identifiers in the column name are redundant. If you are referring to a code, use convention 2.3. For date/time columns, ActiveRecord recommends using the logical proposition form.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>CREATED_ON (Date)</li>
<li>CREATED_AT (Date + time)</li>
<li>STATUS_ID</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>DATE_CREATED</li>
<li>CREATE_DATE</li>
<li>STATUS_CD</li>
</ul>
<h4>Convention #3.4 – Avoid abbreviations in column names</h4>
<p>Do not use abbreviations that are not universal accepted. A good standard is to avoid all abbreviations except those that are defined in one of the official English Language Dictionaries. For example, abbreviations like SSN and ID are acceptable but DT, NUM and CD are not.</p>
<p><strong>Recommended naming:</strong></p>
<ul>
<li>ID (for Primary Key Only)</li>
<li>URL</li>
<li>FIRST_NAME</li>
<li>LAST_4_DIGITS_OF_SSN</li>
</ul>
<p><strong>Not recommended:</strong></p>
<ul>
<li>IDENT</li>
<li>FIRST_NM</li>
<li>LST_4_SSN</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2006/06/16/designing-databases-with-activerecord-conventions/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Setting up Intel Mac for Rails development</title>
		<link>http://mandhro.com/2006/06/16/setting-up-intel-mac-for-rails-development/</link>
		<comments>http://mandhro.com/2006/06/16/setting-up-intel-mac-for-rails-development/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 21:31:47 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.mandhro.com/?p=4</guid>
		<description><![CDATA[I am happy to report back that I had no problems switching to MacOS as my development server. Moreover, MacOS interface felt just natural - as if I always knew how to use it. It could be because of all the things that Ubuntu and GNOME has taken from MacOS, like the preferences dialog, and [...]]]></description>
			<content:encoded><![CDATA[<p>I am happy to report back that I had no problems switching to MacOS as my development server. Moreover, MacOS interface felt just natural - as if I always knew how to use it. It could be because of all the things that Ubuntu and GNOME has taken from MacOS, like the preferences dialog, and privileged commands (sudo). I also felt readily productive in MacOS once I figured out how to launch the terminal. Bash and VIM, my two favorite console tools were already installed.  Here is a report on the tools I configured to migrate from Ubuntu:</p>
<h3>Firefox</h3>
<p>As of writing, Firefox official releases were only for PowerPC, which runs extremely slow emulated on the Intel platform. I had to get the bleeding edge build of Firefox Universal Binary. Fortunately, you can <a href="http://wiki.mozilla.org/Mac:Intel">grab the official release</a> now.</p>
<h3>Ruby on Rails 1.1.1</h3>
<p>After googling around for a few hours and trying different RoR packagers, I found a nice, non-intrusive Mac Intel package at <a href="http://gabrito.com/post/ruby-on-rails-mac-osx-intel-binary">Todd Huss's blog</a>. Unlike Locomotive, which is a PowerPC application that hides the underlying Rails infrastructure, Todd's package gives you a simple directory structure with Ruby and the basic gems that you can drop anywhere on your filesystem.</p>
<h3>MySQL 5.0</h3>
<p>MySQL was a breeze. Just head on over to the <a href="http://dev.mysql.com/downloads/mysql/5.0.html">official MySQL site</a> and grab the Mac x86 version.</p>
<h3>DarwinPorts</h3>
<p>Okay, here's where it gets interesting: Before I can install RMagick (ImageMagick) and Subversion for Intel, I need to setup DarwinPorts so that I can compile my own binaries. For DarwinPorts, I need Xcode. So, I grabbed the latest Intel compatible Xcode from <a href="http://developer.apple.com/tools/download/">Apple's Developer Connection</a>. Grabbed and installed Darwin Ports from <a href="http://darwinports.opendarwin.org/getdp/">here</a>, and followed instructions on <a href="http://rmagick.rubyforge.org/install-osx.html">RubyForge</a> to install ImageMagick and RMagick.</p>
<div align="center"><strong>If you're a Linux user, you'd want to get DarwinPorts, it lets you search, download, compile and install programs much like yum and aptitude.</strong></div>
<h3>Subversion and Lighttpd</h3>
<p>With DarwinPorts installed, installing subversion and lighttpd were a matter of single commands:</p>
<pre>port install subversion port install lighttpd</pre>
<p>I used svnadmin to create a new svn respository, copied my svn repository from Ubuntu, and voila! All my versioned files and change history is migrated. Don't you love it when software just works? Hope this post was helpful to anyone trying to setup an Intel Mac as a Rails development server.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2006/06/16/setting-up-intel-mac-for-rails-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java will learn from and adopt to Rails</title>
		<link>http://mandhro.com/2006/06/16/3/</link>
		<comments>http://mandhro.com/2006/06/16/3/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 21:10:22 +0000</pubDate>
		<dc:creator>Zak Mandhro</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.mandhro.com/?p=3</guid>
		<description><![CDATA[Ruby on Rails is proof, complex web applications don't have to be complicated. Big kudos to David Heinemeier Henson and the Rails committers. Thanks for the wake-up call.   The question is, what do we do with Java now? In the long run, what matters is whether the developer community at large is going [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails is proof, complex web applications don't have to be <span style="font-style: italic">complicated</span>. Big kudos to <a href="http://www.loudthinking.com/about.html">David Heinemeier Henson</a> and the <a href="http://www.rubyonrails.com/core">Rails committers</a>. Thanks for the wake-up call.   The question is, what do we do with Java now? In the long run, what matters is whether the developer community at large is going to learn from it and adopt it or whether it is going to dismiss Rails as a fad. Here's the good news: Java community is no fool, it is learning and it's learning fast.  I was at JavaOne 2006 and here's why I think <span style="font-weight: bold">Java will learn from and adopt to Rails</span>. Like me, you can be a huge Rails fan and a die-hard <span style="font-style: italic">rubist</span>, but you can not deny the ubiquious Java ecosystem, nor can you deny the great innovation that has come from Java's cross platform enterprise environment. At the risk of sounding like an apologist, I hereby claim that Java will learn from Rails and take it to the next level.  Enough claims, here's my list of reasons:</p>
<ol>
<li><a href="http://groovy.codehaus.org/">Groovy</a> (Java Virtual Machine's scripting language) has the benefits of Python and Ruby, such as duck-typing, closures, method-missing, builders, etc. <span style="font-weight: bold">plus</span> the big advantage of running in the highly optimized Java virtual machine, enjoying HotSpot technology and native threads. With the advent of scripting languages support in the JVM with <a href="http://jcp.org/en/jsr/detail?id=223">Mustang (Java 6)</a>. Groovy will get a big boost in performance -- all the productivity minus the interpretation. Whether Ruby enthusiasts agree or not, there is a huge performance gain in running within an intermediate language such Java bytecode. As far as I can see, there is not much information on Ruby 2.0 and it's <a href="http://www.rubyist.net/%7Ematz/slides/rc2003/mgp00007.html">VM</a>. Mustang is open, it's on track, and it will be delivered this year. I sure hope Ruby 2.0 is  chugging along, but I just can't find any evidence online. My money is on Mustang.</li>
<li><a href="http://grails.org/">Grails,</a> the Rails copy-cat for Groovy, is onto a great start. <a href="http://graemerocher.blogspot.com/">Graeme Rocher</a> is certainly embracing the Rails conventions while staying pure to the Java platform by embracing Hibernate. At version 0.1, it's already looking pretty darn impressive. Not a Rails alternative, mind you - but a great start nonetheless. <a href="http://www.rifers.org">RIFE</a> and <a href="https://trails.dev.java.net/">Trails</a> deserve an honorable mentions for highly productive Java environments.</li>
<li>What is the biggest advantage of Rails? For me, it's convention over configuration; not having to write all the darn XML files that only describe the obvious. Good news: The era of useless descriptors is over. <a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html">EJB 3.0</a> sports <a href="http://today.java.net/pub/a/today/2005/08/18/ejb3.html">smart defaults</a>. In essence, it follows the Rails <span style="font-style: italic">convention over configuration</span> paradigm. You no longer have to describe the obvious. As far as I am concerned, the biggest advantage of Rails over Java has just been <span style="font-style: italic">deprecated</span>. With that said, I still think Ruby on Rails has many other advantages over Java. Ruby's dynamic nature and all the flexibility that it makes possible, such as open-classes, meta-programming and Rails plug-ins. RJS templates, fast and simple automated testing, and Rake are some of my favorites that have not made it to the Java world yet.</li>
<li>Last but not least, Java will be open-source. I was there when <a href="http://news.zdnet.com/2100-9593_22-6072760.html">Rich Green said so</a>. My Ubuntu Linux will have a .deb package for Sun Java. Java will no longer be Sun propeitory technology. There will no longer be a need for <span style="font-style: italic">spending life on</span> open source alternatives such as <a href="http://www.mono-project.com/Main_Page">Mono</a> or even Ruby. Java can re-unite the open source community.</li>
</ol>
<p>The point: Rails is wonderful. Ruby is fantastic. Java will adopt and take Ruby on Rails to the next level. That's a few months to a year down the road. I am not holding my breath for Grails, Mustang or open-source Java. I love Ruby on Rails and I will continue to use it. But I <span style="font-style: italic">will</span> keep my eyes and ears open for what Java will become. You should too. Until then, <span style="font-weight: bold">viva la Rails</span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mandhro.com/2006/06/16/3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.350 seconds -->
