<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Railstic</title>
	
	<link>http://railstic.com</link>
	<description>sharing experiences</description>
	<lastBuildDate>Mon, 15 Jun 2009 15:42:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Railstic" /><feedburner:info uri="railstic" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>41.012410</geo:lat><geo:long>28.965454</geo:long><item>
		<title>Nested Object Forms with has_one Relation</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/5YXjeCKeTRc/</link>
		<comments>http://railstic.com/2009/06/nested-object-forms-with-has_one-relation/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 15:40:30 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railstic.com/?p=138</guid>
		<description><![CDATA[Rails 2.3 has a good solution for multi model forms. But there is not much examples of  how to use accepts_nested_attributes_for with has_one relation.
Assume that we have a Book model which has one Author.



Controller :

View:


No special action is needed for create method of BooksController,  attr_accessible is not necessary for Book model. Just don&#8217;t forget to [...]]]></description>
			<content:encoded><![CDATA[<p>Rails 2.3 has a good solution for multi model forms. But there is not much examples of  how to use<code> <strong>accepts_nested_attributes_for</strong></code> with <code><strong>has_one</strong></code> relation.</p>
<p>Assume that we have a Book model which has one Author.<br />
<script src="http://snipt.net/embed/821f03288846297c2cf43c34766a38f7" type="text/javascript"><!--mce:0--></script><br />
<script src="http://snipt.net/embed/02bd92faa38aaa6cc0ea75e59937a1ef" type="text/javascript"><!--mce:1--></script><br />
<br />
Controller :<script src="http://snipt.net/embed/f0ef6bf2d1b0bc59796999ff717bf149" type="text/javascript"><!--mce:2--></script><br />
<br />
View:<br />
<script src="http://snipt.net/embed/2b2d98bcfa219f53623aa6c1f1301a01" type="text/javascript"><!--mce:3--></script><br />
<br />
No special action is needed for <strong><code>create</code></strong> method of BooksController,  <strong>attr_accessible</strong> is not necessary for Book model. Just don&#8217;t forget to add the second parameter (<strong><code>@book</code></strong>) of <strong><code>form_for</code></strong> and build your nested object (@book.build_author).</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/5YXjeCKeTRc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2009/06/nested-object-forms-with-has_one-relation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://railstic.com/2009/06/nested-object-forms-with-has_one-relation/</feedburner:origLink></item>
		<item>
		<title>Tidbit: Converting Strings with Line Feed to Array</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/0ZEEWSjy0Qc/</link>
		<comments>http://railstic.com/2009/01/tidbit-converting-strings-with-line-feed-to-array/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 10:08:02 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railstic.com/?p=126</guid>
		<description><![CDATA[If you have trouble when converting string to array, check if your string includes any line feed (\n). Check how Array("string") behaves:

irb&#40;main&#41;:001:0&#62; Array&#40;&#34;izzet emre \nkutlu&#34;&#41;
=&#62; &#91;&#34;izzet emre \n&#34;, &#34;kutlu&#34;&#93;

This output is not what most of the people expected. Be careful!
]]></description>
			<content:encoded><![CDATA[<p>If you have trouble when converting string to array, check if your string includes any line feed (\n). Check how <code>Array("string")</code> behaves:</p>

<div class="wp_codebox"><table><tr id="p1262"><td class="code" id="p126code2"><pre class="bash" style="font-family:monospace;">irb<span style="color: #7a0874; font-weight: bold;">&#40;</span>main<span style="color: #7a0874; font-weight: bold;">&#41;</span>:001:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">&gt;</span> Array<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;izzet emre <span style="color: #000099; font-weight: bold;">\n</span>kutlu&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;izzet emre <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #ff0000;">&quot;kutlu&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<p>This output is not what most of the people expected. Be careful!</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/0ZEEWSjy0Qc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2009/01/tidbit-converting-strings-with-line-feed-to-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://railstic.com/2009/01/tidbit-converting-strings-with-line-feed-to-array/</feedburner:origLink></item>
		<item>
		<title>WorkingWithRails WordPress Plugin</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/iQGZ8AfeOZs/</link>
		<comments>http://railstic.com/2008/12/workingwithrails-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 20:39:45 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://railstic.com/?p=103</guid>
		<description><![CDATA[
A simple plugin which displays Working With Rails recommendation badge.


Download the plugin.
Extract the plugin to your wordpress plugin directory.
Activate the plugin.
Add the widget to your sidebar.
Enter your information.



It&#8217;s version is 0.1 so comments will be appreciated.
]]></description>
			<content:encoded><![CDATA[<p>
A simple plugin which displays <a href="http://www.workingwithrails.com" target="_blank">Working With Rails</a> recommendation badge.
</p>
<ol style="padding-left:30px">
<li><a href="http://railstic.com/wp-content/uploads/wwrails_badge.zip">Download</a> the plugin.</li>
<li>Extract the plugin to your wordpress plugin directory.</li>
<li>Activate the plugin.</li>
<li>Add the widget to your sidebar.</li>
<li>Enter your information.</li>
</ol>
<p></p>
<p>
It&#8217;s version is 0.1 so comments will be appreciated.</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/iQGZ8AfeOZs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2008/12/workingwithrails-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://railstic.com/2008/12/workingwithrails-wordpress-plugin/</feedburner:origLink></item>
		<item>
		<title>Rails 2.2 &amp; Inflector</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/u7C2kFK1hVo/</link>
		<comments>http://railstic.com/2008/12/rails-22-inflector/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 22:14:52 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[inflector]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://izzetemrekutlu.com/blog/?p=92</guid>
		<description><![CDATA[If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application:

/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in
`load_missing_constant': uninitialized constant Inflector (NameError)

As I learned from Paul&#8217;s post usage of Inflector class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is yourApp/config/initializers/inflections.rb
inflections.rb (Rails [...]]]></description>
			<content:encoded><![CDATA[<p>If you have recently updated to Rails 2.2.2, you may encounter this error when you want to start your application:</p>

<div class="wp_codebox"><table><tr id="p926"><td class="code" id="p92code6"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>1.8<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activesupport-2.2.2<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_support<span style="color: #000000; font-weight: bold;">/</span>dependencies.rb:445:<span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000; font-weight: bold;">`</span>load_missing_constant<span style="color: #ff0000;">': uninitialized constant Inflector (NameError)</span></pre></td></tr></table></div>

<p>As I learned from <a href="http://paulsturgess.co.uk/articles/show/76-load_missing_constant-uninitialized-constant-inflector-when-upgrading-to-ruby-on-rails-222" target="_blank">Paul&#8217;s post</a> usage of <code>Inflector</code> class is changed a bit. You can see the difference when you compare the inflections.rb files. Path of the file is <em>yourApp/config/initializers/inflections.rb</em></p>
<p>inflections.rb (Rails 2.1.0)</p>

<div class="wp_codebox"><table><tr id="p927"><td class="code" id="p92code7"><pre class="ruby" style="font-family:monospace;"> <span style="color:#CC00FF; font-weight:bold;">Inflector</span>.<span style="color:#9900CC;">inflections</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>inflect<span style="color:#006600; font-weight:bold;">|</span>
  .
  .
  .
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>inflections.rb (Rails 2.2.2)</p>

<div class="wp_codebox"><table><tr id="p928"><td class="code" id="p92code8"><pre class="ruby" style="font-family:monospace;"> ActiveSupport::<span style="color:#CC00FF; font-weight:bold;">Inflector</span>.<span style="color:#9900CC;">inflections</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>inflect<span style="color:#006600; font-weight:bold;">|</span>
  .
  .
  .
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>In my situation changing <code>Inflector</code> to <code>ActiveSupport::Inflector</code> was enough to solve the problem.</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/u7C2kFK1hVo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2008/12/rails-22-inflector/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://railstic.com/2008/12/rails-22-inflector/</feedburner:origLink></item>
		<item>
		<title>Updating RubyGems to 1.2 (Manually)</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/hg7Twoe8KDs/</link>
		<comments>http://railstic.com/2008/08/updating-rubygems-to-12-manually/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 12:34:50 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://izzetemrekutlu.com/blog/?p=45</guid>
		<description><![CDATA[
This is what happened when I want to install rmagick gem.


username@username-desktop:~$ sudo gem install rmagick
Bulk updating Gem source index for: http://gems.rubyforge.org/
ERROR:  could not find rmagick locally or in a repository


What the hell&#8230;
After some googling I found that RubGems 1.1.x is buggy and and update to RubyGems 1.2 is necessary.
To learn your RubyGems version:


username@username-desktop:~$ gem [...]]]></description>
			<content:encoded><![CDATA[<p>
This is what happened when I want to install rmagick gem.<br />
</p>

<div class="wp_codebox"><table><tr id="p4515"><td class="code" id="p45code15"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rmagick
Bulk updating Gem <span style="color: #7a0874; font-weight: bold;">source</span> index <span style="color: #000000; font-weight: bold;">for</span>: http:<span style="color: #000000; font-weight: bold;">//</span>gems.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>
ERROR:  could not <span style="color: #c20cb9; font-weight: bold;">find</span> rmagick locally or <span style="color: #000000; font-weight: bold;">in</span> a repository</pre></td></tr></table></div>

<p>
What the hell&#8230;<br />
After some googling I found that RubGems 1.1.x is buggy and and update to RubyGems 1.2 is necessary.<br />
To learn your RubyGems version:<br />
</p>

<div class="wp_codebox"><table><tr id="p4516"><td class="code" id="p45code16"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~$ gem <span style="color: #660033;">-v</span>
1.1.0</pre></td></tr></table></div>

<p><span id="more-45"></span><br />
 I try to update RubyGems :<br />
</p>

<div class="wp_codebox"><table><tr id="p4517"><td class="code" id="p45code17"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem update <span style="color: #660033;">--system</span>
Updating RubyGems
Bulk updating Gem <span style="color: #7a0874; font-weight: bold;">source</span> index <span style="color: #000000; font-weight: bold;">for</span>: http:<span style="color: #000000; font-weight: bold;">//</span>gems.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>
Nothing to update</pre></td></tr></table></div>

<p>
After this failed attempt, I realized that RubyGems 1.1.x is really buggy. So I must go on manually to update RubyGems.<br />
<br />
<strong>Now the solution:</strong><br />
</p>
<ol>
<li>
Download <a href="http://rubyforge.org/frs/download.php/38844/rubygems-update-1.2.0.gem">rubygems-update-1.2.0.gem</a>
</li>
<li>
Change your directory where your downloaded gem is. In these example my gem is at Desktop.<br />
Now you must install <em>rubygems-update-1.2.0.gem</em>.</p>

<div class="wp_codebox"><table><tr id="p4518"><td class="code" id="p45code18"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~$ <span style="color: #7a0874; font-weight: bold;">cd</span> Desktop<span style="color: #000000; font-weight: bold;">/</span>
username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rubygems-update-1.2.0.gem</pre></td></tr></table></div>

</li>
<li>

<div class="wp_codebox"><table><tr id="p4519"><td class="code" id="p45code19"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~<span style="color: #007800;">$sudo</span> update_rubygems</pre></td></tr></table></div>

</li>
</ol>
<p>
To check if our process is successful :<br />
</p>

<div class="wp_codebox"><table><tr id="p4520"><td class="code" id="p45code20"><pre class="bash" style="font-family:monospace;">username<span style="color: #000000; font-weight: bold;">@</span>username-desktop:~<span style="color: #007800;">$gem</span> <span style="color: #660033;">-v</span>
1.2.0</pre></td></tr></table></div>

<p>
If you see <em>1.2.0</em>, you did it.</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/hg7Twoe8KDs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2008/08/updating-rubygems-to-12-manually/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://railstic.com/2008/08/updating-rubygems-to-12-manually/</feedburner:origLink></item>
		<item>
		<title>Recursive methods with block in Ruby</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/G-MqRkXuTnc/</link>
		<comments>http://railstic.com/2008/08/recursive-methods-with-block/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 10:46:17 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://izzetemrekutlu.com/blog/?p=20</guid>
		<description><![CDATA[

def comic&#40;cast&#41;
   cast.each do &#124;character&#124;
      unless character.is_a?&#40;Array&#41;
         yield&#40;character&#41;
      else
	 comic&#40;character&#41; &#123;&#124;x&#124; yield x&#125;
      end
   end
end


This method takes an array as argument and checks each element if it is [...]]]></description>
			<content:encoded><![CDATA[<p></p>

<div class="wp_codebox"><table><tr id="p2024"><td class="code" id="p20code24"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> comic<span style="color:#006600; font-weight:bold;">&#40;</span>cast<span style="color:#006600; font-weight:bold;">&#41;</span>
   cast.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>character<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#9966CC; font-weight:bold;">unless</span> character.<span style="color:#9900CC;">is_a</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">Array</span><span style="color:#006600; font-weight:bold;">&#41;</span>
         <span style="color:#9966CC; font-weight:bold;">yield</span><span style="color:#006600; font-weight:bold;">&#40;</span>character<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
	 comic<span style="color:#006600; font-weight:bold;">&#40;</span>character<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#9966CC; font-weight:bold;">yield</span> x<span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>
This method takes an array as argument and checks each element if it is an <em>Array</em>.<br />
If the element is not an <em>Array</em> then the block is called.<br />
If the element is an <em>Array</em> then the same method is called with that element as an argument and with the same block.<br />
<br />
Now let&#8217;s look how we can call this method.</p>

<div class="wp_codebox"><table><tr id="p2025"><td class="code" id="p20code25"><pre class="ruby" style="font-family:monospace;">names = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'lucky luke'</span>, <span style="color:#996600;">'jolly jumper'</span>, <span style="color:#996600;">'rin tin tin'</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'joe'</span>, <span style="color:#996600;">'william'</span>,<span style="color:#996600;">'jack'</span>, <span style="color:#996600;">'averell'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
comic<span style="color:#006600; font-weight:bold;">&#40;</span>names<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">puts</span> c<span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

<p>
<strong>Output :</strong></p>

<div class="wp_codebox"><table><tr id="p2026"><td class="code" id="p20code26"><pre class="bash" style="font-family:monospace;">lucky luke
jolly jumper
rin tin tin
joe
william
jack
averell</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/Railstic/~4/G-MqRkXuTnc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2008/08/recursive-methods-with-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://railstic.com/2008/08/recursive-methods-with-block/</feedburner:origLink></item>
		<item>
		<title>How to check if a div exists in rjs?</title>
		<link>http://feedproxy.google.com/~r/Railstic/~3/fc15ZhgEqVw/</link>
		<comments>http://railstic.com/2008/08/how-to-check-if-a-div-exists-in-rjs/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 17:52:36 +0000</pubDate>
		<dc:creator>İzzet Emre Kutlu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rjs]]></category>

		<guid isPermaLink="false">http://izzetemrekutlu.com/blog/?p=3</guid>
		<description><![CDATA[

&#60;body&#62;
   &#60;div id='main'&#62;
      Main Div
   &#60;/div&#62;
&#60;/body&#62;



render :update do &#124;page&#124;
   page &#60;&#60; &#34;if ($('main')){&#34;
   page.replace_html 'main', :inline =&#62; 'Here it is'
   page &#60;&#60; &#34;}&#34;
end

This ruby code checks if there is a DOM object that its id = &#8220;main&#8221;.
If there is then [...]]]></description>
			<content:encoded><![CDATA[<p></p>

<div class="wp_codebox"><table><tr id="p329"><td class="code" id="p3code29"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span>
   <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'main'</span>&gt;</span>
      Main Div
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span></pre></td></tr></table></div>

<p></p>

<div class="wp_codebox"><table><tr id="p330"><td class="code" id="p3code30"><pre class="ruby" style="font-family:monospace;">render <span style="color:#ff3333; font-weight:bold;">:update</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>page<span style="color:#006600; font-weight:bold;">|</span>
   page <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;if ($('main')){&quot;</span>
   page.<span style="color:#9900CC;">replace_html</span> <span style="color:#996600;">'main'</span>, <span style="color:#ff3333; font-weight:bold;">:inline</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Here it is'</span>
   page <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;}&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>This ruby code checks if there is a DOM object that its id = &#8220;main&#8221;.<br />
If there is then changes its content to &#8220;Here it is&#8221;, if there is not do nothing.</p>
<img src="http://feeds.feedburner.com/~r/Railstic/~4/fc15ZhgEqVw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railstic.com/2008/08/how-to-check-if-a-div-exists-in-rjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://railstic.com/2008/08/how-to-check-if-a-div-exists-in-rjs/</feedburner:origLink></item>
	</channel>
</rss>
