<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ai ♥ Ruby on Rails</title>
	<atom:link href="http://ailoveruby.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ailoveruby.wordpress.com</link>
	<description>Let&#039;s build a powerful, dynamic website!</description>
	<lastBuildDate>Thu, 10 Jun 2010 04:39:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ailoveruby.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ai ♥ Ruby on Rails</title>
		<link>http://ailoveruby.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ailoveruby.wordpress.com/osd.xml" title="Ai ♥ Ruby on Rails" />
	<atom:link rel='hub' href='http://ailoveruby.wordpress.com/?pushpress=hub'/>
		<item>
		<title>My blog has been moved</title>
		<link>http://ailoveruby.wordpress.com/2010/06/10/my-blog-has-been-moved/</link>
		<comments>http://ailoveruby.wordpress.com/2010/06/10/my-blog-has-been-moved/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 04:38:40 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=257</guid>
		<description><![CDATA[Hello, my blog has been moved to: http://railsblog.ainakatani.com<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=257&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Hello, my blog has been moved to:</h4>
<h4><a title="New Ai Love Ruby on Rails" href="http://railsblog.ainakatani.com" target="_blank"><span style="color:#000000;">http://railsblog.ainakatani.com</span></a></h4>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/257/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/257/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/257/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=257&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/06/10/my-blog-has-been-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>
	</item>
		<item>
		<title>Meta tags on RoR</title>
		<link>http://ailoveruby.wordpress.com/2010/06/04/meta-tags-on-ror/</link>
		<comments>http://ailoveruby.wordpress.com/2010/06/04/meta-tags-on-ror/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 06:53:03 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=252</guid>
		<description><![CDATA[On my website Mixed Baby Name, I have a dedicated page for each baby name.  For example, the name Ai is on this page. Because I use layout &#8216;application&#8216;, by default, all of the pages&#8217; title, keywords, and description were same as specified in layouts/application.html.erb I wanted to show a baby name on the browser [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=252&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On my website <a title="Mixed Baby Name" href="http://www.mixedbabyname.com" target="_blank">Mixed Baby Name</a>, I have a dedicated page for each baby name.  For example, the name Ai is on <a title="Ai - Mixed Baby Name" href="http://mixedbabyname.com/babynames/62" target="_blank">this page</a>.</p>
<p>Because I use <strong>layout &#8216;application</strong>&#8216;, by default, all of the pages&#8217; title, keywords, and description were same as specified in <em><strong>layouts/application.html.erb</strong></em></p>
<p>I wanted to show a baby name on the browser tab (title) so that when the multiple pages are open on tabs, the users will know which page is on which tab. Bookmarking would also be easier.</p>
<p>I found this article by SEO on Rails very useful: <a title="SEO on Rails article" href="http://www.seoonrails.com/getting-your-meta-tags-on-track.html" target="_blank">Getting your meta tags on track </a></p>
<p>Now each of the name pages has a unique title.  Also, when you click on a flag, the new page title also contains the region name.</p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F06%2F04%2Fmeta-tags-on-ror%2F&amp;linkname=Meta%20tags%20on%20RoR"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/252/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=252&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/06/04/meta-tags-on-ror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>How to clean up whitespace</title>
		<link>http://ailoveruby.wordpress.com/2010/06/04/how-to-clean-up-whitespace/</link>
		<comments>http://ailoveruby.wordpress.com/2010/06/04/how-to-clean-up-whitespace/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 00:00:21 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ruby Operations]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=239</guid>
		<description><![CDATA[Sometimes when you ask a user an input, he/she may include white space before/after the actual input by mistake. You may want to clean them up before saving the input into the database. Same can be said when the user performs a search.  On my website Mixed Baby Name, if the user types &#8216;Ai   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=239&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">Sometimes when you ask a user an input, he/she may include white space before/after the actual input by mistake.</div>
<div>You may want to clean them up before saving the input into the database.</div>
<div>Same can be said when the user performs a search.  On my website <a title="Mixed Baby Name" href="http://www.mixedbabyname.com" target="_blank">Mixed Baby Name</a>, if the user types</div>
<div style="padding-left:30px;">&#8216;Ai    &#8217;</div>
<div>or</div>
<div style="padding-left:30px;">&#8216;    Ai&#8217;</div>
<div>or even worse,</div>
<div style="padding-left:30px;">&#8216;    Ai     &#8216;</div>
<div>instead of  just &#8216;Ai&#8217; to look for my name, I have to make sure that the user won&#8217;t get an empty result.</div>
<div>The method you are looking for is <strong><span style="color:#ff0000;">strip</span></strong>.</div>
<div>I find <span style="color:#ff0000;"><strong>strip!</strong></span> (with the ! mark) very useful, because it does a strip <span style="text-decoration:underline;">in place</span>.</div>
<div>For your models, you can write a piece of code like this in your model to ensure that your records won&#8217;t have any white space at the beginning and end.</div>
<div style="padding-left:30px;">class<em> Babyname</em> &lt; ActiveRecord::Base</div>
<div id="_mcePaste" style="padding-left:60px;"><span style="color:#ff0000;"><strong>before_validation :</strong></span><em>delete_whitespace</em></div>
<div id="_mcePaste" style="padding-left:60px;"><span style="color:#ff0000;"><strong>def</strong></span> <em>d</em><em>elete_whitespace</em></div>
<div id="_mcePaste" style="padding-left:90px;"><span style="color:#ff0000;"><strong>self.</strong></span><em>name</em>.<span style="color:#ff0000;"><strong>strip! </strong></span></div>
<div id="_mcePaste" style="padding-left:60px;"><strong><span style="color:#ff0000;">end</span></strong></div>
<div style="padding-left:30px;">end</div>
<div>This will define and call the function delete_whitespace before any kind of validation happens  (such as presence of other attributes and uniqueness of the attribute, etc.)</div>
<div>You can also want to add a line of code like this  after the strip to ensure that only the first letter is capitalized.</div>
<div style="padding-left:30px;">self.name.<span style="color:#ff0000;"><strong>capitalize!</strong></span></div>
<div>For example, this will change the name entry &#8220;AI&#8221; or &#8220;ai&#8221; into &#8220;Ai&#8221; in place.</div>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F06%2F04%2Fhow-to-clean-up-whitespace%2F&amp;linkname=How%20to%20clean%20up%20whitespace"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/239/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=239&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/06/04/how-to-clean-up-whitespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>Joining attributes into a string</title>
		<link>http://ailoveruby.wordpress.com/2010/06/03/joining-multiple-strings/</link>
		<comments>http://ailoveruby.wordpress.com/2010/06/03/joining-multiple-strings/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 23:31:26 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ruby Operations]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=232</guid>
		<description><![CDATA[If you have multiple objects and you want to show certain attributes as one string, with, for example, a comma in between, you write: &#60;%= objects.map(&#38;:attribute).join(&#8216;, &#8216;) %&#62; For example, if I want to output a string consisting some objects(say babynames)&#8217; names, I write: &#60;%= babynames.map(&#38;:name).join(&#8216;, &#8216;) %&#62; The output will be something like: Andrew, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=232&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have multiple objects and you want to show certain attributes as one string, with, for example, a comma in between, you write:</p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">&lt;%=</span> </strong><em>objects</em><strong><span style="color:#ff0000;">.map(&amp;:</span><span style="color:#ff0000;"><span style="font-weight:normal;"><em><span style="color:#000000;">a</span></em><em><span style="color:#000000;">ttribute</span></em></span></span></strong><strong><span style="color:#ff0000;">).joi<span style="color:#ff0000;">n(</span></span><span style="color:#ff0000;">&#8216;</span></strong><em>,</em><strong><span style="color:#ff0000;"> &#8216;) %&gt;</span></strong></p>
<p><span style="color:#ff0000;"><strong><span style="color:#000000;"><span style="font-weight:normal;">For example, if I want to output a string consisting some objects(say babynames)&#8217; names, I write:</span></span></strong></span></p>
<p style="padding-left:30px;"><span style="color:#ff0000;"><strong><span style="color:#000000;"><span style="font-weight:normal;"><strong>&lt;%= </strong><em>babynames</em><strong>.map(&amp;:</strong><em>name</em><strong>).join(&#8216;</strong><em>,</em><strong> &#8216;) %&gt;</strong></span></span></strong></span></p>
<p>The output will be something like:</p>
<p style="padding-left:30px;">Andrew, Chris, Oliver, Anna</p>
<p>This is nice because you don&#8217;t have to write a loop and check whether to add a comma (or period or whatever) after each name.</p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F06%2F03%2Fjoining-multiple-strings%2F&amp;linkname=Joining%20multiple%20strings"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=232&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/06/03/joining-multiple-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>auto_complete to check the uniqueness</title>
		<link>http://ailoveruby.wordpress.com/2010/05/30/auto_complete-to-check-the-uniqueness/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/30/auto_complete-to-check-the-uniqueness/#comments</comments>
		<pubDate>Sun, 30 May 2010 02:17:02 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=226</guid>
		<description><![CDATA[In my website (Mixed Baby Name), when users try to enter a name which is already registered, I wanted to let them to know that the name is already registered and at the same time give a link to the page. (If you want to see the example, please visit the entry form here and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=226&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my website (<a title="Mixed Baby Name" href="http://www.mixedbabyname.com" target="_blank">Mixed Baby Name</a>), when users try to enter a name which is already registered, I wanted to let them to know that the name is already registered and at the same time give a link to the page.</p>
<p>(If you want to see the example, please visit the entry form <a title="Entry form" href="http://www.mixedbabyname.com/babynames/new" target="_blank">here </a>and type a name &#8216;Ai&#8217; which already exists in the database)</p>
<p>I read <a title="SciWerks.com auto_complete to ensure uniqueness" href="http://www.sciwerks.com/blog/2006/10/09/using-an-auto_complete-to-ensure-uniqueness/" target="_blank">this article</a> at <a title="SciWerks.com" href="http://www.sciwerks.com/" target="_blank">SciWerks.com</a> and changed the code here and there so that a newbie like me can understand it easily.</p>
<p>I have a model called <em>babyname</em>, and it has <em>name </em>as an attribute.</p>
<p>Here is what I did:</p>
<p>In my babyname  &#8216;new&#8217; view file, I had the following code inside the entry form:</p>
<p style="padding-left:30px;"><span style="color:#ff0000;"><strong>&lt;%= </strong></span><strong><span style="color:#ff0000;">text_field_with_auto_complete</span><span style="color:#ff0000;"> :</span></strong><em>babyname</em><span style="color:#ff0000;"><strong>, :</strong></span><em>name</em> <strong><span style="color:#ff0000;">%&gt;</span></strong></p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">&lt;div id=</span></strong>&#8216;<em>name_error</em>&#8216;<span style="color:#ff0000;"><strong>&gt;&lt;/div&gt;</strong></span></p>
<p>And in my controller, I put the following code:</p>
<p><strong><span style="color:#ff0000;">def auto_complete_for_</span></strong><em>babyname</em><strong><span style="color:#ff0000;">_</span></strong><em>name</em></p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">@</span></strong><em>babyname</em> = <em>Babyname</em>.<strong><span style="color:#ff0000;">find_by_</span></strong><em>name</em><span style="color:#ff0000;"><strong>(params[:</strong></span><em>babyname</em><span style="color:#ff0000;"><strong>][:</strong></span><em>name</em><span style="color:#ff0000;"><strong>])</strong></span><br />
<span style="color:#ff0000;"><strong>if @</strong></span><em>babyname</em></p>
<p style="padding-left:60px;"><strong><span style="color:#ff0000;">render :update do |page|</span></strong></p>
<p style="padding-left:90px;"><strong><span style="color:#ff0000;">page.replace_html </span></strong>&#8216;<em>name_error&#8217;</em>, <strong><span style="color:#ff0000;">link_to(&#8216;</span></strong><em>Name is already registered. Click here to view the details.</em><strong><span style="color:#ff0000;">&#8216;, </span><span style="color:#ff0000;">@</span></strong><em>babyname</em><strong><span style="color:#ff0000;">)</span></strong></p>
<p style="padding-left:60px;"><strong><span style="color:#ff0000;">e</span><span style="color:#ff0000;">nd </span></strong></p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">else</span></strong></p>
<p style="padding-left:60px;"><strong><span style="color:#ff0000;">render :update do |page|</span></strong></p>
<p style="padding-left:90px;"><strong><span style="color:#ff0000;">page.replace_html &#8216;</span></strong><em>name_error</em><strong><span style="color:#ff0000;">&#8216;, &#8220;&#8221;</span></strong></p>
<p style="padding-left:60px;"><strong><span style="color:#ff0000;">end<br />
</span></strong></p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">end</span></strong></p>
<p><span style="color:#ff0000;"><strong>end</strong></span></p>
<p><strong><br />
</strong></p>
<p>That&#8217;s it. As the user types a character, it checks whether the string matches any name in the babynames table. If the name is found, then it shows (insert) the error message (at &lt;div&gt;&lt;/div&gt; tags) as a link to that name page. If not, it shows an empty string (that is, no error message).</p>
<p>If you don&#8217;t want to have a link and want to show only the error message, you can replace one line of code with this:</p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;">page.replace_html</span><span style="color:#ff0000;"> &#8216;</span></strong><em>name_error</em><strong><span style="color:#ff0000;">&#8216;, &#8220;</span></strong><em>Name is already registered</em><strong><span style="color:#ff0000;">&#8220;</span></strong></p>
<p><span style="color:#ff0000;"><span style="color:#000000;">You can also use this technique to ensure the uniqueness of user ID, email address, etc. like I did on <a title="Mixed Baby Name Sign-up page" href="http://www.mixedbabyname.com/signup" target="_blank">this page</a>.</span></span><strong><span style="color:#ff0000;"><br />
</span></strong></p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F05%2F30%2Fauto_complete-to-check-the-uniqueness%2F&amp;linkname=auto_complete%20to%20check%20the%20uniqueness"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/226/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=226&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/30/auto_complete-to-check-the-uniqueness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>Running Rails on Your Main Domain at HostMonster</title>
		<link>http://ailoveruby.wordpress.com/2010/05/24/running-rails-on-your-main-domain-at-hostmonster/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/24/running-rails-on-your-main-domain-at-hostmonster/#comments</comments>
		<pubDate>Mon, 24 May 2010 20:10:09 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ai's Rails Projects]]></category>
		<category><![CDATA[HostMonster]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=216</guid>
		<description><![CDATA[I wrote the following article: Rails Setup and Subdomains at HostMonster What if you don&#8217;t want any subdomains? What if you want your Rails project to run on the main domain itself (for instance, http://www.mixedbabyname.com)? I asked HostMonster support and got the following answer (they were nice enough to do it themselves and let me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=216&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wrote the following article: <a href="2010/05/18/rails-setup-and-subdomains-at-hostmonster/" target="_blank">Rails Setup and Subdomains at HostMonster </a></p>
<p>What if you don&#8217;t want any subdomains? What if you want your Rails project to run on the main domain itself (for instance, <a title="Mixed Baby Name" href="http://www.mixedbabyname.com" target="_blank">http://www.mixedbabyname.com</a>)?</p>
<p>I asked HostMonster support and got the following answer (they were nice enough to do it themselves and let me know what they did!)</p>
<p style="padding-left:30px;">I renamed <span style="color:#ff0000;"><strong>public_html</strong></span> to <strong><span style="color:#ff0000;">public_html-old</span></strong>.  I then ran this command:</p>
<p style="padding-left:30px;">&gt; <em>username@domain.com</em><strong><span style="color:#ff0000;"> [~]# ln -s ~/rails</span>/</strong><em>project_name</em><strong>/<span style="color:#ff0000;">public public_html</span></strong></p>
<p style="padding-left:30px;">This created a symlink for your main domain to the public folder of the project_name rails app.  Now, when visiting <a href="http://mixedbabyname.com/" target="_blank">http://mixedbabyname.com</a> , it pulls up your rails app automatically.</p>
<p>These guys are so nice <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F05%2F24%2Frunning-rails-on-your-main-domain-at-hostmonster%2F&amp;linkname=Running%20Rails%20on%20Your%20Main%20Domain%20at%20HostMonster"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=216&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/24/running-rails-on-your-main-domain-at-hostmonster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL Character Set</title>
		<link>http://ailoveruby.wordpress.com/2010/05/24/mysql-character-set/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/24/mysql-character-set/#comments</comments>
		<pubDate>Mon, 24 May 2010 19:49:52 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[HostMonster]]></category>
		<category><![CDATA[Localization and Foreign Languages]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=210</guid>
		<description><![CDATA[When I was developing and testing my website locally using RadRails, I had no problem with writing/showing/storing Japanese characters in the database or files. Then I signed up for my HostMonster account, got the domain and transferred all of my data, and BOOM! All of my Japanese character strings in the database became a bunch [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=210&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I was developing and testing my website locally using RadRails, I had no problem with writing/showing/storing Japanese characters in the database or files.</p>
<p>Then I signed up for my HostMonster account, got the domain and transferred all of my data, and BOOM! All of my Japanese character strings in the database became a bunch of random characters.</p>
<p>By default, the character set for HostMonster&#8217;s MySQL database is latin1. Try this command to see the settings:</p>
<p><strong>&gt; <span style="color:#ff0000;">show variables like &#8216;character_set%&#8217;;</span></strong></p>
<p><strong><span style="color:#ff0000;"> </span></strong>I tried to change them, but I couldn&#8217;t. I was stupid enough to ask  HostMonster support to change the settings and got the following response: &#8220;Those variables will not be modified on the root because other clients  on this shared server are dependent on these settings being constant.&#8221;</p>
<p>However, we can change the settings for our own database (HostMonster&#8217;s Response):</p>
<p style="padding-left:30px;">You can set the collation of the table to use a specific Character Set.   Log into the <span style="color:#ff0000;"><strong>cPanel</strong></span> and click the <strong><span style="color:#ff0000;">phpMyAdmin</span></strong>.  Right column, select the  database&#8217;s name and then the table name where this data is stored.   Click the <strong><span style="color:#ff0000;">Operations </span></strong>tab along top and find the drop-down list to  select the desired collation for the language you use. Alternatively,  you may run the SQL command such as</p>
<p style="padding-left:30px;"><strong><span style="color:#ff0000;"><span style="color:#ff0000;">&gt; </span>ALTER DATABASE </span></strong><em>databasename</em> <span style="color:#ff0000;"><strong>CHARACTER SET utf8 COLLATE utf8_general_ci</strong></span>;</p>
<p>One thing to note is that you MUST change the character set of the database <span style="text-decoration:underline;">before</span> making any tables and columns.</p>
<p>The tables and columns settings (yes, each table and column has its own character settings) depend on the database settings <span style="text-decoration:underline;">at the time of the creation</span>.</p>
<p>So, if you already made tables and columns and wish to change the entire settings, I propose that you drop all of the tables, change the database settings, and then re-create tables and transfer all of the data.</p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F05%2F24%2Fmysql-character-set%2F&amp;linkname=MySQL%20Character%20Set"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=210&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/24/mysql-character-set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Japanese (Asian Language) Websites</title>
		<link>http://ailoveruby.wordpress.com/2010/05/24/making-japanese-asian-language-websites/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/24/making-japanese-asian-language-websites/#comments</comments>
		<pubDate>Mon, 24 May 2010 19:27:37 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ai's Rails Projects]]></category>
		<category><![CDATA[Localization and Foreign Languages]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=206</guid>
		<description><![CDATA[If you are an English speaker, you may have never bothered to make your website multilingual. I speak Japanese, so most of my websites need to show Japanese characters. Before making a Japanese website, you have to create the following environment: Operating System &#8211; Your computer should be able to show and type Japanese characters  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=206&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are an English speaker, you may have never bothered to make your website multilingual.</p>
<p>I speak Japanese, so most of my websites need to show Japanese characters.</p>
<p>Before making a Japanese website, you have to create the following environment:</p>
<ul>
<li>Operating System &#8211; Your computer should be able to show and type Japanese characters  (I use Windows XP&#8217;s English version, so I had to install Asian characters on my computer in order to read and write Japanese. Go to <strong><span style="color:#ff0000;">Control Panel</span></strong> )</li>
</ul>
<ul>
<li>Development software &#8211; Your text editing software or any software you use to create website must have Japanese character sets. These days most of the software  do.  Back in old days, I could count the number of text editing software that was made in English yet could read/write Japanese!</li>
<li> Server &#8211; Make sure your database&#8217;s character set is UTF8 or some other character set that can properly store the language you are intending to use.</li>
</ul>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F05%2F24%2Fmaking-japanese-asian-language-websites%2F&amp;linkname=Making%20Japanese%20(Asian%20Language)%20Websites"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=206&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/24/making-japanese-asian-language-websites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding Orphans in MySQL database</title>
		<link>http://ailoveruby.wordpress.com/2010/05/23/finding-orphans-in-mysql-database/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/23/finding-orphans-in-mysql-database/#comments</comments>
		<pubDate>Sun, 23 May 2010 21:19:42 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=201</guid>
		<description><![CDATA[I&#8217;m using this entry as my notepad I forgot to set &#8220;cascade delete&#8221; to my tables.  So, when I deleted an entry, the dependents&#8217; records associated with that entry remained in the database.  In other words, these records became orphans. They have a foreign key which no longer exists. This can throw an error when [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=201&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using this entry as my notepad <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I forgot to set &#8220;cascade delete&#8221; to my tables.  So, when I deleted an entry, the dependents&#8217; records associated with that entry remained in the database.  In other words, these records became orphans. They have a foreign key which no longer exists. This can throw an error when I access the children table and try to use this foreign key to get the deleted parent&#8217;s information.</p>
<p>Say, we have two tables: <em>parents</em> and <em>children</em>.  The children table belongs to the parents table, so the children table has a column called <em>parent_id</em>, which is associated with the unique <em>id</em> in the parents table.</p>
<p>This command looks for orphans&#8217; deceased parents&#8217; ids.</p>
<p>&gt; <span style="color:#ff0000;"><strong>select</strong></span> <em>parent_id</em> <strong><span style="color:#ff0000;">from</span></strong> <em>children</em> <span style="color:#ff0000;"><strong>where</strong></span> <em>parent_id</em> <strong><span style="color:#ff0000;">NOT IN(</span></strong>select <em>id</em> from <em>parents</em><strong><span style="color:#ff0000;">);</span></strong></p>
<p>If this returns an empty set,  there is no orphen.</p>
<p>Alternatively, you can also do this to simply  look for the orphans&#8217; ids.</p>
<p>&gt; <strong>select</strong> <em>id</em> <strong>from</strong> <em>children</em> <strong>where</strong> <em>parent_id</em> <strong>NOT  IN(</strong>select <em>id</em> from <em>parents</em><strong>);</strong></p>
<p><a href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Failoveruby.wordpress.com%2F2010%2F05%2F23%2Ffinding-orphans-in-mysql-database%2F&amp;linkname=Finding%20Orphans%20in%20MySQL%20database"><img src="http://static.addtoany.com/buttons/share_save_256_24.png" alt="Share" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=201&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/23/finding-orphans-in-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>

		<media:content url="http://static.addtoany.com/buttons/share_save_256_24.png" medium="image">
			<media:title type="html">Share</media:title>
		</media:content>
	</item>
		<item>
		<title>Launching Development Console in Rails</title>
		<link>http://ailoveruby.wordpress.com/2010/05/23/launching-development-console-in-rails/</link>
		<comments>http://ailoveruby.wordpress.com/2010/05/23/launching-development-console-in-rails/#comments</comments>
		<pubDate>Sun, 23 May 2010 20:54:12 +0000</pubDate>
		<dc:creator>Ai</dc:creator>
				<category><![CDATA[Ruby Commands]]></category>

		<guid isPermaLink="false">http://ailoveruby.wordpress.com/?p=199</guid>
		<description><![CDATA[Just type in your console: &#62;ruby script/console To check if it&#8217;s working,  just type something like: &#62;Tablename.find(:all) This should show all of the entries in that table.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=199&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just type in your console:</p>
<p>&gt;<span style="color:#ff0000;"><strong>ruby script/console</strong></span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;">To check if it&#8217;s working,  just type something like:</span></span><br />
&gt;<em>Tablename</em>.find(:all)</p>
<p>This should show all of the entries in that table.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ailoveruby.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ailoveruby.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ailoveruby.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ailoveruby.wordpress.com&amp;blog=11758935&amp;post=199&amp;subd=ailoveruby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ailoveruby.wordpress.com/2010/05/23/launching-development-console-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8225a8d9ac9af724e2ca402aff6b75f3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ai</media:title>
		</media:content>
	</item>
	</channel>
</rss>
